set_modification_statement


Description:

public bool set_modification_statement (Statement mod_stmt) throws Error

Informs this that it should allow modifications to the data in some columns and some rows using mod_stmt to propagate those modifications into the database.

If mod_stmt is: <itemizedlist> <listitem><para>an UPDATE statement, then all the rows in this will be writable</para></listitem> <listitem><para>a DELETE statement, then it will be possible to delete rows in this</para></listitem> <listitem><para>in INSERT statement, then it will be possible to add some rows to this</para></listitem> <listitem> <para>any other statement, then this method will return an error</para></listitem> </itemizedlist>

This method can be called several times to specify different types of modification statements.

Each modification statement will be executed when one or more values are modified in the data model; each statement should then include variables which will be set to either the old value or the new value of a column at the specified modified row (but can also contain other variables). Each variable named as "+&lt;number&gt;" will be mapped to the new value of the number'th column (starting at 0), and each variable named as "-&lt;number&gt;" will be mapped to the old value of the number'th column.

Examples of the SQL equivalent of each statement are (for example if "mytable" has the "id" field as primary key, and if that field is auto incremented and if the data model is the result of executing "<![CDATA[SELECT * from mytable]]>").

<itemizedlist> <listitem><para>"<![CDATA[INSERT INTO mytable (name) VALUES (##+1GdaDataSelect::string)]]> ": the column ID can not be set for new rows</para></listitem> <listitem><para>"<![CDATA[DELETE FROM mytable WHERE id=##-0GdaDataSelect::int]]>"</para></listitem> <listitem><para>"<![CDATA[UPDATE mytable SET name=##+1GdaDataSelect::string WHERE id=##-0GdaDataSelect::int]]>": the column ID cannot be modified</para> </listitem> </itemizedlist>

Also see the set_row_selection_condition_sql for more information about the WHERE part of the UPDATE and DELETE statement types.

If mod_stmt is an UPDATE or DELETE statement then it should have a WHERE part which identifies a unique row in this (please note that this property can't be checked but may result in this behaving in an unpredictable way).

NOTE1: However, if the set_row_selection_condition or set_row_selection_condition_sql have been successfully be called before, the WHERE part of mod_stmt <emphasis>WILL</emphasis> be modified to use the row selection condition specified through one of these methods (please not that it is then possible to avoid specifying a WHERE part in mod_stmt then).

NOTE2: if set_row_selection_condition or set_row_selection_condition_sql have not yet been successfully be called before, then the WHERE part of mod_stmt will be used as if one of these functions had been called.

Parameters:

this

a DataSelect data model

mod_stmt

a Statement (INSERT, UPDATE or DELETE)

Returns:

true if no error occurred.