rewrite_statement_for_null_parameters


Description:


[ Version ( since = "4.2.9" ) ]
public bool rewrite_statement_for_null_parameters (Statement stmt, Set @params, out Statement? out_stmt) throws Error

Modifies stmt to take into account any parameter which might be null: if stmt contains the equivalent of "xxx = <parameter definition>" and if that parameter is in params and its value is of type GDA_TYPE_NUL, then that part is replaced with "xxx IS NULL".

It also handles the "xxx IS NOT NULL" transformation.

For example the following SELECT: <programlisting>SELECT * FROM data WHERE id = #id::int::null AND name = # name::string</programlisting> in case the "id" parameter is set to NULL, is converted to: <programlisting>SELECT * FROM data WHERE id IS NULL AND name = #name::string</programlisting>

if out_stmt is not null, then it will contain: <itemizedlist> <listitem><para >the modified statement if some modifications were required and no error occured (the function returns true )</para></listitem> <listitem><para>null if no modification to stmt were required and no erro occurred (the function returns false)</para></listitem> <listitem> <para>null if an error occured (the function returns true)</para ></listitem> </itemizedlist>

This function is used by provider's implementations to make sure one can use parameters with NULL values in statements without having to rewrite statements, as database usually don't consider that "xxx = NULL" is the same as "xxx IS NULL" when using parameters.

Parameters:

stmt

a Statement

out_stmt

a place to store the new Statement, or null

params

a Set to be used as parameters when executing stmt

Returns:

true if stmt needs to be transformed to handle NULL parameters, and false otherwise


Namespace: Gda
Package: libgda-6.0