[ Version ( since = "4.2.3" ) ]
public bool delete_row_from_table (string table, string condition_column_name, Value condition_value) throws Error
This is a convenience function, which creates a DELETE statement and executes it using the values provided.
It internally relies on variables which makes it immune to SQL injection problems.
The equivalent SQL command is: DELETE FROM <table> WHERE <condition_column_name> = <condition_value >.
A simple example to remove a row in database.
GdaConnection *cnc;
//Open connection here
GError *error = NULL;
GValue *v_id = gda_value_new (G_TYPE_INT);
GValue *v_name = gda_value_new_from_string ("Aldibino Refinino", G_TYPE_STRING);
//The number 10 represents a primary key record in the table
g_value_set_int (v_id, 10);
//Delete a record with a specific ID in the col_id column
if (!gda_connection_delete_row_from_table (cnc, "TABLE_CONTACTS",
"col_id", v_id,
&error))
{
g_error ("Could not delete row in table: %s\n",
error && error->message ? error->message : "No detail");
}
//Delete a record with a specific NAME in the col_name column
if (!gda_connection_delete_row_from_table (cnc, "TABLE_CONTACTS",
"col_name", v_name,
&error))
{
g_error ("Could not delete row in table: %s\n",
error && error->message ? error->message : "No detail");
}
gda_value_free (v_id);
gda_value_free (v_name);
g_error_free (error);
this |
an opened connection |
table |
the table's name with the row's values to be updated |
condition_column_name |
the name of the column to used in the WHERE condition clause |
condition_value |
the |
TRUE if no error occurred, FALSE otherwise |