Bindable parameters also called dynamic parameters or bind variables—are an alternative way to pass data to the database. Instead of putting the values directly into the SQL statement, you just use a placeholder "?".
Code Block |
---|
language | sql |
---|
title | Example use of bindable parameters |
---|
|
SELECT * FROM core.issues WHERE author = ? AND id > ? |
Each time you use a query with bind parameters you will be prompted to fill the values for them. This works in:
- Navigator for queries
- Gadgets with selected view which is a query with such parameters
You can save a query with bind parameters as a custom view or share such view just like any other.
There is one difference in using a view with bind parameters as a part of a greater query - you must treat such view as a table function rather than a table. See examples:
Code Block |
---|
language | sql |
---|
title | Using a custom view with 2 bind parameters |
---|
|
SELECT * FROM TABLE(CUSTOM.SOMEVIEWWITHBINGPARAMS(bind-param-1, bind-param-2)) |
Code Block |
---|
language | sql |
---|
title | Using a shared view with 2 bind parameters |
---|
|
SELECT * FROM TABLE(SHArED.SOMEUSER.SOMEVIEWWITHBINGPARAMS(bind-param-1, bind-param-2)) |