How many variables in SQL.Text

djk

Member
I have a function that retrieves SQL script from a table, loads it into a TOracleQuery and executes it.

This SQL may contain various amounts of variables. Is there any way, other tan parsing the string, to work out how many & what variables are in the string so that I can declare them?
 
To find bind variables in a piece of SQL, you can use the FindVariables function in the Oracle unit:

function FindVariables(const SQL: string; IncludeDuplicates: Boolean): TStringList;

The SQL parameter is the SQL you want to analyze. If a bind variable appears more than once in the SQL, the IncludeDuplicates parameter controls if it also appears more than once in the result. The result is a TStringList instance (which you must free later). The Objects property of the result contains and integer value that indicates the position in the SQL where the corresponding variable is located.

------------------
Marco Kalter
Allround Automations
 
Back
Top