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:

  • an UPDATE statement, then all the rows in this will be writable
  • a DELETE statement, then it will be possible to delete rows in this
  • in INSERT statement, then it will be possible to add some rows to this
  • any other statement, then this method will return an error

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 "+<number>" will be mapped to the new value of the number'th column (starting at 0), and each variable named as "-<number>" 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 "SELECT * from mytable").

  • "INSERT INTO mytable (name) VALUES (##+1::string)": the column ID can not be set for new rows
  • "DELETE FROM mytable WHERE id=##-0::int"
  • "UPDATE mytable SET name=##+1::string WHERE id=##-0::int": the column ID cannot be modified

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 gda_data_select_set_row_selection_condition or set_row_selection_condition_sql have been successfully be called before, the WHERE part of mod_stmt WILL 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 gda_data_select_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.