Using Parameters in your Query

Standard parameter syntax

In Coginiti, you can apply various parameters in the queries:

  1. To do so, insert the $symbol in any part of your SQL statement.
  2. When you execute a query, the application will ask you to fill in a parameter's value before sending a query to a database.
1 --sample parameter query
2
3 select *
4 from landing_dim_customer
5 where gender = $fill_in_gender_at_runtime
6 limit 100;
  1. The application will provide you with the following data type at runtime:

Parameter Data Type

Action Taken

As Is

Coginiti will send entered value exactly as written, with no casting. This feature often helps when you use a parameter to fill in the database table or column names.

  1. You can specify default values by using this syntax with your parameters:

$fill_in_gender_at_runtime{‘M’}

When you run a query with all your parameters, you'll see the little gear icon as shown below. Click on it to populate the default value if needed.

mceclip0.png

🔎 Note: If you're using a column with the text format, please, keep in mind that you need to add ‘’ or “” symbols into the designated field in the Run query with parameters pop-up.

Alternative parameter syntax

We are pleased to announce that starting from Coginiti v22.02, we support an alternative parameter syntax so that you can specify both, parameters and session variables in the queries:

  1. Select $$<name> in settings:
    Alternative_parameter_syntax.png
  2. Type a query:
    SET (MIN, MAX)=(5.0, 499.99);
    SELECT AVG(TOTAL_PRICE) from ORDERS
    WHERE TOTAL_PRICE BETWEEN $MIN AND $MAX
    AND PAYMENT_CURRENCY = $$currency{'EUR'};
  3. Execute the query and fill in the parameter’s value:
    Screenshot_2022-04-04_at_11.50.58.png

    🔎 Note: You only need to specify the value of $$currency as it is a parameter. The session variables MIN and MAX are set in the 1st line.

  4. Get the result:
    Screenshot_2022-04-04_at_11.51.40.png
Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request