SQL  procedures

Top  Previous  Next

Here the SQL queries can be set. This part requires SQL language knowledge.

 

 

clip0059

 

1. The  databases used (access the databases structures)

       - only one it is shown here - that can be Northwind, but any other ones can be chosen, if proper        connections between them are correctly created.

               - Ex: For a sales & HR database the following data will be required:

                       - at least a table codes of employees from;

                       -  the 2 databases, when is mandatory to integrate;

                       -  the data, from the 2 databases to the same report.

       - data and structure can be seen

       - this control can be hidden using the vertical shape on right of the control.

 

2. SQL Queries

       - save each query under a name.

       - their number may vary and can be as many as needed

       - the query can be manually written (right text edit or text editor clip0060) or a visual query editor can be used clip0061.

 

clip0062

 

Each query can be tested by pressing the clip0064 button.

It is recommended to test each query right after creating it.

 

3. To set up the code that runs last on server:

RUNSQL(<sqlname>)    - runs the SQL query named <sqlname>

RETURNSQL(<sqlnqme>) - return SQL result.

 

Between those commands, SQL's that collect data from multiple sources can be inserted.

Available new functions:

       -    _month (<date field>) - returns month like "M2011.01"  from "2011-01-01"

       -    _quarter (<date field>) - returns quarter from date like "Q2011-01'

 

Sample:

 

RunSQL('first')

 

select _month(first.orderdate) as month,_quarter(first.orderdate) as quarter,first.* from first into cursor second

 

ReturnSQL('second')

All queries can be tested at once by pressing clip0064 button here.