The loader reads the SQL file contents as a string and considers it to be an SQL query. The SQL statement is compiled into a function, which we will call the "SQL function", to distinguish it from the "SQL file". The SQL function executes the SQL query as required.
The SQL function requires at least one argument, which must be a database connection, as returned by the jdbcconn loader. Any subsequent arguments are assumed to be parameters to the SQL query and may be of any valid type(integer, string, date, etc).
The format of an SQL file is simply any valid SQL statement (starting with SELECT) for the database you intend to query. As the SQL query is executed as a prepared statement, you can specify variable parameters to the query by using a "?" character.
SELECT
*
FROM
images
WHERE
site_id = ?
AND
language = ?
OR
some_other_field = 'a value'
localhost.jdbcconn
sql file in your inventory, containing the
SQL query for your database. Any variable parameters you want can be
specified as "?". This example will assume you have created a file
called images.sql.
SELECT
*
FROM
images
WHERE
site_id = ?
AND
language = ?
images( localhost, "lemeridien", "french" );
SELECT
*
FROM
images
WHERE
site_id = 'lemeridien'
AND
language = 'french'