[gnome-db] Meta store and check if column exists



Hi!

Do I need to update meta store (gda_connection_update_meta_store())
when I only check if particular column in table exists?

Code which works:

GdaMetaContext mcontext = {"_columns", 2, NULL, NULL};
        mcontext.column_names = g_new (gchar *, 2);
        mcontext.column_names[0] = "table_name";
        mcontext.column_names[1] = "column_name";
        mcontext.column_values = g_new (GValue *, 2);
g_value_set_string ((mcontext.column_values[0] = gda_value_new (G_TYPE_STRING)), table_name); g_value_set_string ((mcontext.column_values[1] = gda_value_new (G_TYPE_STRING)), column_name);


GdaDataModel *dm_schema =
gda_connection_get_meta_store_data (mgd->priv->connection, GDA_CONNECTION_META_FIELDS, NULL, 2,
                       "name", mcontext.column_values[0],
                       "field_name", mcontext.column_values[1]);

if (gda_data_model_get_n_rows (dm_schema) == 0)
	return FALSE; /* column doesn't exist */

In case of SQLite, when column exists, and I update meta store, warn
ing is thrown: 'constraint failed'. Without such update, there's no warning. Of course, meta store is updated when column is created in table.

Piotras


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]