Top | ![]() |
![]() |
![]() |
![]() |
GQuark | gda_db_index_error_quark () |
GdaDbIndex * | gda_db_index_new () |
void | gda_db_index_set_unique () |
gboolean | gda_db_index_get_unique () |
void | gda_db_index_append_field () |
void | gda_db_index_remove_field () |
GSList * | gda_db_index_get_fields () |
The object GdaDbIndex holds information about index in a table. Just populate the information
using index API, set table as property, execute gda_ddl_modifiable_create()
method. This
method executes all needed DB manopulations to add the target index to the DB. This can be
illustarted by the following example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
GdaDbTable *table = gda_db_table_new(); // Populate table as needed. GdaDbIndex *index = gda_db_index_new (); GdaDbIndexField *field = gda_db_index_field_new (); GdaDbColumn *fcol = gda_db_column_new (); GError *error = NULL; gda_db_index_set_unique (index, TRUE); gda_db_base_set_name (GDA_DB_BASE (index), "MyIndex"); gda_db_column_set_name (fcol, "name"); gda_db_index_field_set_column (field, fcol); gda_db_index_field_set_sort_order (field, GDA_DB_INDEX_SORT_ORDER_ASC); gda_db_index_append_field (index, field); g_object_unref (fcol); g_object_unref (field); g_object_set (index, "table", table, NULL); res = gda_ddl_modifiable_create (GDA_DDL_MODIFIABLE(index), cnc, NULL, &error); if (!res) g_print("Error during index addition\n"); |
void gda_db_index_set_unique (GdaDbIndex *self
,gboolean val
);
If val
is TRUE
a "UNIQUE" will be added to the INDEX CREATE command, e.g.
CREATE UNIQUE INDEX ...
Since: 6.0
Stability Level: Stable
gboolean
gda_db_index_get_unique (GdaDbIndex *self
);
Since: 6.0
Stability Level: Stable
void gda_db_index_append_field (GdaDbIndex *self
,GdaDbIndexField *field
);
Append to index filed to the current index instance, The self
object will recieve full
ownership of the field. After this call, the reference count for field
will be increased and
the instance of fiels
must be destroyed by calling g_object_unref()
Since: 6.0
Stability Level: Stable
void gda_db_index_remove_field (GdaDbIndex *self
,const gchar *name
);
Since: 6.0
Stability Level: Stable
GSList *
gda_db_index_get_fields (GdaDbIndex *self
);
This function is thread safe, that is, cnc
will be locked.
Since: 6.0
Stability Level: Stable
“table”
property“table” GdaDbTable *
Table associated with index.
Owner: GdaDbIndex
Flags: Read / Write