SQL Variables
|
Here you have the option to define up to 20 SQL Variables ([%0], [%1], [%2], [%3] … [%19]). Compared to Formatted Searches we need to have defined the variables type and description.
In order to define the variable sources, press the Wizard button.
Column
|
Description
|
Variable
|
The variable you are defining the source for
|
Source
|
The Source. It can a custom value or a list of common values like Business partners etc.
If can find the list of value you wish you also have the option to define a SQL sentence that should retrieve the values as a combo box.
|
Caption
|
The caption of the variable (The text shown when prompting the user for the value)
|
Source SQL
|
If you in the Source select SQL as source, you define the SQL here (else it is not used). The SQL sentence should be a SELECT statement with two selected columns. first value will be seen as the value of the selection and second will be seen as the description.
SELECT <VALUE>,<DESCRIPTION> FROM <TABLE>
Sample: SELECT CardCode, CardName FROM OCRD
would result in a list of all Business Partners. CardCode will be the value for the customer select and CardName will be the description that help them choose the value.
|
Title
|
The title of the window shown when prompting the user for the values
NB: THE DEFAULT TITLE IS ‘DEFINE SURVEY VARIABLES’ IF NO TITLE IS GIVEN.
|
Alternative you can define the SQL Variables syntax manually:
This is done by using the following syntax for each of the 20 variables:
%<id>[<type>|<description>];
If you wish to use the variables, then you can format each by changing the syntax.
The following types are possible
• 0 (treat as string)
• STRING (as above)
• INTEGER (treat as a whole number)
• NUMBER (treat as a number with decimals)
• DATE (treat as a Date)
• YES_NO (combo box with a Yes and No value (Yes is default))
• NO_YES (combo box with a No and a Yes value (No is default))
• Tableid from one of the following to create Choose from Lists:
o Business Partner (OCRD), Items (OITM), Warehouse (OWHS), Sales Opportunity (OOPR), GL Account (OACT), Activity (OCLG), Employee (OHEM), Picklist (OPKL), Customer Equipment Card (OINS), ServiceCall (OSCL), Service Contract (OCTR), Solution Knowledge Base (OSLT), Journal Entry (OJDT), Sales/Purchase Documents (OQUT, ORDR, ODLN, ORDN, OINV, ORIN, ODPI, OPOR, OPDL, ORPD, OPCH, ORPC, ODPO), Incoming Payment (ORCT), Outgoing Payments (OVPM), Goods receipt (OIGN), Goods Issue (OIGE), Production Order (OWOR), Project Codes (OPRJ), Campaign (OCPN).
• Tableid from one of the following to create a combo box with their data
o Item groups (OITB), Sales Employees (OSLP), Shipping types (OSHP), Activitytypes (OCLT), BP Groups (OCRG), BP Groups - Customers (OCRG_C), BP Groups – Suppliers (OCRG_S), BP Priorities (OBPP), Budget distributions methods (OBGD), Countries (OCRY), Currencies (OCRN), Customs groups (OARG), Distribution rules (OOCR), Dunning terms (ODUT), Freight codes (OEXD), Holidays (OHLD), Indicators (OIDC), Inventory Cycles (OCYC), Languages (OLNG), Length and Width UOM (OLGT), Manufactures (OMRC), Payment Methods (OPYM), Payment Methods – In (OPYM_IN), Payment Methods – Out (OPYM_OUT), Payment Terms (OCTG), Pricelists (OPLN), Territories (OTER), Users (OUSR), Weight UOM (OWGT)
• SQL:SELECT <VALUE>,<DESCRIPTION> FROM <TABLE> (treat as combo box with the values from the SQL written).
EXAMPLE 1: IF VARIABLE 0 SHOULD BE OF TYPE DATE AND WITH THE DESCRIPTION "FROM DATE" THE SYNTAX OF %0 SHOULD BE %0[DATE|FROM DATE];
EXAMPLE 2: IF VARIABLE 3 SHOULD BE OF TYPE INTEGER AND WITH THE DESCRIPTION "DOCUMENT NUMBER" THE SYNTAX OF %3 SHOULD BE %3[INTEGER|DOCUMENT NUMBER];
JUST LEAVE THE SYNTAX OF UNUSED VARIABLES SINCE IT ARE IGNORED
Once defined and used in a SQL Report, you will instead of a direct result get a "Define survey variables" window where you enter the prompted data. As shown in this example:
As you can see in the above configuration we use [%0] and [%1] to get a from and a to date. Running the SQL Report will before the result give us the following window where we can enter the from and to date defined (%3, %4 and %5 is not shown since they are not used):
Upon pressing the OK button, we get our result as normal based on the entered from and to dates.
|