Update the meta data about a table: GNOME Data Access 5 manual

## Update the meta data about a table

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;
    GValue *table;
    GdaMetaContext *mcontext = gda_meta_context_new ();
    /* This is a table in the dababase schema for Meta Store to update */
    gda_meta_context_set_table ("_tables");
    /* Next setup a value to be used as the column in the last table to be used as a condition in the update
       in this case we will use the column 'table_name' and update for 'customers'*/
    table = gda_value_new (G_TYPE_STRING);
    g_value_set_string (table, "customers");
    gda_meta_context_set_column ("table_name", table);
    gboolean result;
    result = gda_connection_update_meta_store (connection, mcontext, &error);
    gda_value_free (table);
    gda_meta_context_free (mcontext);
    if (!result) {
        /* handle the error */
        g_error_free (error);
    }

Internally gda_meta_context_set_column() calls gda_sql_identifier_quote() which 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 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.