![]() |
![]() |
![]() |
GNOME Data Access 4 manual | ![]() |
---|
For a general overview of the mete data problem, see the Get information about a table's columns section. Updating the meta data can be done by calling gda_connection_update_meta_store() with a %NULL "context" argument, but this call updates the whole meta data which will always do the job, but sometimes one knows that only a part of the meta data need to be updated. Here is an example of how to use a specific GdaMetaContext argument.
Specifically the following code updates the meta data regarding the "customers" table:
GdaConnection *connection=... GError *error = NULL; GdaMetaContext mcontext = {"_tables", 1, NULL, NULL}; gboolean result; mcontext.column_names = g_new (gchar *, 1); mcontext.column_names[0] = "table_name"; mcontext.column_values = g_new (GValue *, 1); g_value_take_string ((mcontext.column_values[0] = gda_value_new (G_TYPE_STRING)), gda_sql_identifier_quote ("customers")); result = gda_connection_update_meta_store (connection, &mcontext, &error); gda_value_free (mcontext.column_values[0]); if (!result) { /* handle the error */ g_error_free (error); }
An important note about the gda_sql_identifier_quote() call
which has been added to ensure
that the contents of mcontext.column_values
values is
conform to the convention used by the GdaMetaStore
to represent SQL identifiers when the
values represent an SQL identifier (which is the case in the example above). For more information,
see the meta data section about SQL identifiers.
Even though not strictly necessary, it can safely be used all the time. For example if the table name for which a meta data update is requested had been "Customers" (note the upper case C at the beginning and the double quotes) because this is how the database know it, then not using gda_sql_identifier_quote() may not have done as expected.