Friday, May 18, 2012

Optional parameters in SELECT query

Considering the case in which we need a condition to be implemented only if we have the value in the optional parameter. For example, write a SQL query
- To return all the sales lines
- For all sales orders
- For one specific sales order [If the value for the sales id is provided]

Step 1: Create a new class and a new method with optional parameter in the method as shown below:
















Step 2: Write a job to call this method:











Step 3: Running this job, will list all the sales orders as shown in the infolog screen below:































Step 4: Make the modifications in the job and pass a sales order id as shown below:


Step 5: Running this job, will list the items for the passed sales order id only:



This is how we can add the optional parameters in the SELECT queries.



No comments:

Post a Comment