How to set parameters for SQL Query tool report

By | February 28, 2024

In Sage X3, we may come across a situation where we need to create SQL query tool by adding fields from the table.

There was one requirement from one of our clients to add parameters (filters) for the SQL query tool in the criteria tab.

In this blog, we will explore the process of assigning parameters to the SQL query tool based on client-specific requirements. So, we have added two parameters, ‘From Date’ and ‘To Date’.

We will see this functionality in detail in this blog:

Path>>setup>>Usage>>Reports>>SQL query tool

New Stuff: How to solve Error: “@X3.TRT/SUBSDHA$adx (2612) Error 6 : Variable Non-existent GLBDOCDAT” in Sage X3

Create SQL query
Create SQL query

Initially, formulate a SQL query in accordance with the client’s requirements. When incorporating parameters into the SQL query, ensure to enclose the parameter number within %% symbols as shown in the above screen shot.

For Example:
select * from SINVOICE where SINVOICE.INVDAT_0 between %1% and %2%

Path >> setup >> Usage >> Reports >> SQL query tool >> Parameter

Set Parameter Description, Datatype, and Default Values
Set Parameter Description, Datatype, and Default Values

Navigate to the Parameters tab and add the necessary parameters, specifying the desired data type. If a default value is needed for a parameter, enter the default value in the ‘Default’ column.

We have added ‘Date From’ and ‘Date To’ to the Parameter column, assigning a default value using the current date$ function.

Validate and run query
Validate and run query

After adding the parameter, click on the ‘validate’ button to validate the query, and then click on the ‘Run‘ button to execute it.

Path : Path >> setup >> Usage >> Reports >> SQL query tool >> Run button

Criteria button
Criteria button

Click on the ‘Criteria‘ button.

Popup for Parameters
Popup for Parameters

So, in conclusion, we have successfully added parameters to this query tool. Now, users can manually enter the required parameters, click on ‘Ok,’ and filter the query according to their specific needs, thereby enhancing the flexibility and usability of the report.