rewrite_for_default_values


Description:

[ Version ( since = "4.2" ) ]
public SqlStatement? rewrite_for_default_values (Set @params, bool remove) throws Error

Rewrites this and creates a new SqlStatement where all the variables which are to a DEFAULT value (as returned by value_is_default) are either removed from the statement (if remove is true) or replaced by the "DEFAULT" keyword (if remove is false).

This function is only useful for database providers' implementations which have to deal with default values when executing statements, and is only relevant in the case of INSERT or UPDATE statements (in the latter case an error is returned if remove is true).

For example the <programlisting><![CDATA[INSERT INTO mytable (id, name) VALUES (23, #name::string)]]>< /programlisting> is re-written into <programlisting><![CDATA[INSERT INTO mytable (id, name) VALUES (23, DEFAULT)]]>< /programlisting> if remove is false and into <programlisting><![CDATA[INSERT INTO mytable (id) VALUES (23)]]></programlisting> if remove is true.

Parameters:

this

a Statement object

remove

set to true if DEFAULT fields are removed, of false if the "DEFAULT" keyword is used

params

a Set containing the variable's values to be bound when executing this

Returns:

a new SqlStatement, or null if an error occurred