3.8.1. SQL bind variables Previous topic Parent topic Child topic Next topic

Most SQL servers support the use of bind variables. Bind variables are used by the SQL server to do a dynamic replacement of variables in an SQL statement. In some SQL servers this can increase query performance by allowing the server to compile and reuse the SQL compiled SQL query many times.
With Radiator SQL clause query parameters that support bind variables, you can specify the query separately from the values for the bind variables. With most SQL servers, the position of each bound variable is marked by a question mark (‘?’) character. The bound variables will be replaced (after special characters are replaced) at run-time one by one in the order of the question marks in the query, and in the order of the bound variable specifications.
For example, <AuthBy SQL> supports bound variables with the AuthSelect query parameter. In this sample configuration fragment:
AuthSelect select PASSWORD from SUBSCRIBERS where USERNAME=? and CLIENT=?
AuthSelectParam %0
AuthSelectParam %N
%0 (user name) will be used to replace the first ? (the one for the USERNAME column), and %N (NAS id) will be used to replace the second (the one for the CLIENT column).
Some SQL queries are cached when configured with bind variables. By default as much as 32 queries can be cached. This can be changed in SqlDb.pm if required.
Note
Most SQL servers and their Perl DBD modules support bound variables. Check the documentation for your SQL server, and the Perl DBD module for your server.