Top | ![]() |
![]() |
![]() |
![]() |
Any type of constraint in a database is represented by one instance of the class (see the possible types of constraints). As some constraints may not depend exclusively on a table, all the constraints are attached to the database itself.
It implements the GdaXmlStorage and GdaReferer interfaces.
GdaDictConstraint * gda_dict_constraint_new (GdaDictTable *table
,GdaDictConstraintType type
);
Creates a new GdaDictConstraint object
GdaDictConstraint *
gda_dict_constraint_new_with_db (GdaDictDatabase *db
);
Creates a new GdaDictConstraint object without specifying anything about the constraint except the database it is attached to. This is usefull only when the object is going to be loaded from an XML node.
GdaDictConstraintType
gda_dict_constraint_get_constraint_type
(GdaDictConstraint *cstr
);
Get the type of constraint the cstr
object represents
gboolean gda_dict_constraint_equal (GdaDictConstraint *cstr1
,GdaDictConstraint *cstr2
);
Compares two GdaDictConstraint objects to see if they are equal, without taking into account the name of the constraints or weather they are user or system defined
cstr1 |
the first GdaDictConstraint to compare |
|
cstr2 |
the second GdaDictConstraint to compare |
GdaDictTable *
gda_dict_constraint_get_table (GdaDictConstraint *cstr
);
Get the table to which the constraint is attached
gboolean gda_dict_constraint_uses_field (GdaDictConstraint *cstr
,GdaDictField *field
);
Tests if field
is part of the cstr
constraint
void gda_dict_constraint_pkey_set_fields (GdaDictConstraint *cstr
,const GSList *fields
);
Sets the fields which make the primary key represented by cstr
. All the fields
must belong to the same GdaDictTable to which the constraint is attached
GSList *
gda_dict_constraint_pkey_get_fields (GdaDictConstraint *cstr
);
Get the list of fields composing the primary key constraint which cstr
represents. The
returned list is allocated and must be de-allocated by the caller.
void gda_dict_constraint_fkey_set_fields (GdaDictConstraint *cstr
,const GSList *pairs
);
Sets the field pairs which make the foreign key represented by cstr
. All the field pairs
must list a field which belong to the same GdaDictTable to which the constraint is attached
and a field which belongs to a GdaDictTable which is different from the one just mentionned and which
is within the same database.
The pairs are of type GdaDictConstraintFkeyPair.
GdaDictTable *
gda_dict_constraint_fkey_get_ref_table
(GdaDictConstraint *cstr
);
Get the GdaDictTable at the other end of the foreign key relation represented by this constraint
GSList *
gda_dict_constraint_fkey_get_fields (GdaDictConstraint *cstr
);
Get the list of field pairs composing the foreign key constraint which cstr
represents. In the returned
list, each pair item is allocated and it's up to the caller to free the list and each pair, and the
reference count for each pointer to GObjects in each pair is NOT INCREASED, which means the caller of this
function DOES NOT hold any reference on the mentionned GObjects (if he needs to, it has to call g_object_ref()
)
void gda_dict_constraint_fkey_set_actions (GdaDictConstraint *cstr
,GdaDictConstraintFkAction on_update
,GdaDictConstraintFkAction on_delete
);
Sets the actions undertaken by the DBMS when some actions occur on the referenced data
cstr |
a GdaDictConstraint object |
|
on_update |
the action undertaken when an UPDATE occurs |
|
on_delete |
the action undertaken when a DELETE occurs |
void gda_dict_constraint_fkey_get_actions (GdaDictConstraint *cstr
,GdaDictConstraintFkAction *on_update
,GdaDictConstraintFkAction *on_delete
);
Get the actions undertaken by the DBMS when some actions occur on the referenced data
cstr |
a GdaDictConstraint object |
|
on_update |
an address to store the action undertaken when an UPDATE occurs |
|
on_delete |
an address to store the action undertaken when a DELETE occurs |
void gda_dict_constraint_unique_set_fields (GdaDictConstraint *cstr
,const GSList *fields
);
GSList *
gda_dict_constraint_unique_get_fields (GdaDictConstraint *cstr
);
Get the list of fields represented by this UNIQUE constraint. It's up to the caller to free the list.
void gda_dict_constraint_not_null_set_field (GdaDictConstraint *cstr
,GdaDictField *field
);
GdaDictField *
gda_dict_constraint_not_null_get_field
(GdaDictConstraint *cstr
);