Convenience functions

Convenience functions — Do quickly some actions

Synopsis

GdaServerOperation* gda_prepare_create_database         (const gchar *provider,
                                                         const gchar *db_name,
                                                         GError **error);
gboolean            gda_perform_create_database         (GdaServerOperation *op,
                                                         GError **error);
GdaServerOperation* gda_prepare_drop_database           (const gchar *provider,
                                                         const gchar *db_name,
                                                         GError **error);
gboolean            gda_perform_drop_database           (GdaServerOperation *op,
                                                         GError **error);

GdaDataModel*       gda_execute_select_command          (GdaConnection *cnc,
                                                         const gchar *sql,
                                                         GError **error);
gint                gda_execute_non_select_command      (GdaConnection *cnc,
                                                         const gchar *sql,
                                                         GError **error);

GdaServerOperation* gda_prepare_create_table            (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         GError **error,
                                                         ...);
gboolean            gda_perform_create_table            (GdaServerOperation *op,
                                                         GError **error);
GdaServerOperation* gda_prepare_drop_table              (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         GError **error);
gboolean            gda_perform_drop_table              (GdaServerOperation *op,
                                                         GError **error);

gboolean            gda_insert_row_into_table           (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         GError **error,
                                                         ...);
gboolean            gda_insert_row_into_table_from_string
                                                        (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         GError **error,
                                                         ...);
gboolean            gda_update_value_in_table           (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         const gchar *search_for_column,
                                                         const GValue *condition,
                                                         const gchar *column_name,
                                                         const GValue *new_value,
                                                         GError **error);
gboolean            gda_update_values_in_table          (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         const gchar *condition_column_name,
                                                         const GValue *condition,
                                                         GError **error,
                                                         ...);
gboolean            gda_delete_row_from_table           (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         const gchar *condition_column_name,
                                                         const GValue *condition,
                                                         GError **error);

GdaDataHandler*     gda_get_default_handler             (GType for_type);

Description

Details

gda_prepare_create_database ()

GdaServerOperation* gda_prepare_create_database         (const gchar *provider,
                                                         const gchar *db_name,
                                                         GError **error);

Creates a new GdaServerOperation object which contains the specifications required to create a database. Once these specifications provided, use gda_perform_create_database() to perform the database creation.

If db_name is left NULL, then the name of the database to create will have to be set in the returned GdaServerOperation using gda_server_operation_set_value_at().

provider :

the database provider to use

db_name :

the name of the database to create, or NULL

error :

a place to store errors, or NULL

Returns :

new GdaServerOperation object, or NULL if the provider does not support database creation

gda_perform_create_database ()

gboolean            gda_perform_create_database         (GdaServerOperation *op,
                                                         GError **error);

Creates a new database using the specifications in op, which must have been obtained using gda_prepare_create_database()

op :

a GdaServerOperation object obtained using gda_prepare_create_database()

error :

a place to store en error, or NULL

Returns :

TRUE if no error occurred and the database has been created

gda_prepare_drop_database ()

GdaServerOperation* gda_prepare_drop_database           (const gchar *provider,
                                                         const gchar *db_name,
                                                         GError **error);

Creates a new GdaServerOperation object which contains the specifications required to drop a database. Once these specifications provided, use gda_perform_drop_database() to perform the database creation.

If db_name is left NULL, then the name of the database to drop will have to be set in the returned GdaServerOperation using gda_server_operation_set_value_at().

provider :

the database provider to use

db_name :

the name of the database to drop, or NULL

error :

a place to store errors, or NULL

Returns :

new GdaServerOperation object, or NULL if the provider does not support database destruction

gda_perform_drop_database ()

gboolean            gda_perform_drop_database           (GdaServerOperation *op,
                                                         GError **error);

Destroys an existing database using the specifications in op, which must have been obtained using gda_prepare_drop_database()

op :

a GdaServerOperation object obtained using gda_prepare_drop_database()

error :

a place to store en error, or NULL

Returns :

TRUE if no error occurred and the database has been destroyed

gda_execute_select_command ()

GdaDataModel*       gda_execute_select_command          (GdaConnection *cnc,
                                                         const gchar *sql,
                                                         GError **error);

Execute a SQL SELECT command over an opened connection.

Return: a new GdaDataModel if succesfull, NULL otherwise

cnc :

an opened connection

sql :

a query statament must begin with "SELECT"

error :

a place to store errors, or NULL

Returns :


gda_execute_non_select_command ()

gint                gda_execute_non_select_command      (GdaConnection *cnc,
                                                         const gchar *sql,
                                                         GError **error);

cnc :

sql :

error :

Returns :


gda_prepare_create_table ()

GdaServerOperation* gda_prepare_create_table            (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         GError **error,
                                                         ...);

Create a GdaServerOperation object using an opened connection, taking three arguments, a colum's name the column's GType and GdaEasyCreateTableFlag flag, you need to finish the list using NULL.

You'll be able to modify the GdaServerOperation object to add custom options to the operation. When finish call gda_perform_create_table or gda_server_operation_perform_operation in order to execute the operation.

cnc :

an opened connection

table_name :

num_columns

error :

a place to store errors, or NULL

... :

group of three arguments for column's name, column's GType and a GdaEasyCreateTableFlag flag, finished with NULL

Returns :

a GdaServerOperation if no errors; NULL and set error otherwise

gda_perform_create_table ()

gboolean            gda_perform_create_table            (GdaServerOperation *op,
                                                         GError **error);

Performs a prepared GdaServerOperation to create a table. This could perform an operation created by gda_prepare_create_table or any other using the the GdaServerOperation API.

op :

a valid GdaServerOperation

error :

a place to store errors, or NULL

Returns :

TRUE if the table was created; FALSE and set error otherwise

gda_prepare_drop_table ()

GdaServerOperation* gda_prepare_drop_table              (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         GError **error);

This is just a convenient function to create a GdaServerOperation to drop a table in an opened connection.

cnc :

an opened connection

table_name :

error :

a place to store errors, or NULL

Returns :

a new GdaServerOperation or NULL if couldn't create the opereration.

gda_perform_drop_table ()

gboolean            gda_perform_drop_table              (GdaServerOperation *op,
                                                         GError **error);

This is just a convenient function to perform a drop a table operation.

op :

a GdaServerOperation object

error :

a place to store errors, or NULL

Returns :

TRUE if the table was dropped

gda_insert_row_into_table ()

gboolean            gda_insert_row_into_table           (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         GError **error,
                                                         ...);

This is just a convenient function to insert a row with the values given as argument. The values must correspond with the GType of the column to set, otherwise throw to an error. Finish the list with NULL.

The arguments must be pairs of column name followed by his value.

cnc :

an opened connection

table_name :

error :

a place to store errors, or NULL

... :

a list of string/GValue pairs where the string is the name of the column followed by its GValue to set in the insert operation, finished by NULL

Returns :

TRUE if no error occurred, and FALSE and set error otherwise

gda_insert_row_into_table_from_string ()

gboolean            gda_insert_row_into_table_from_string
                                                        (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         GError **error,
                                                         ...);

This is just a convenient function to insert a row with the values given as arguments. The values must be strings that could be converted to the type in the corresponding column. Finish the list with NULL.

The arguments must be pairs of column name followed by his value.

The SQL command is like: INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...)

cnc :

an opened connection

table_name :

error :

a place to store errors, or NULL

... :

a list of strings to be converted as value, finished by NULL

Returns :

TRUE if no error occurred, and FALSE and set error otherwise

gda_update_value_in_table ()

gboolean            gda_update_value_in_table           (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         const gchar *search_for_column,
                                                         const GValue *condition,
                                                         const gchar *column_name,
                                                         const GValue *new_value,
                                                         GError **error);

This is just a convenient function to update values in a table on a given column where the row is fitting the given condition.

The SQL command is like: UPDATE INTO table_name SET column_name = new_value WHERE search_for_column = condition

cnc :

an opened connection

table_name :

search_for_column :

the name of the column to used in the WHERE condition clause

condition :

a GValue to used to find the value to be updated; it must correspond with the GType of the column used to search

column_name :

the column containing the value to be updated

new_value :

the new value to update to; the GValue must correspond with the GType of the column to update

error :

a place to store errors, or NULL

Returns :

TRUE if no error occurred

gda_update_values_in_table ()

gboolean            gda_update_values_in_table          (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         const gchar *condition_column_name,
                                                         const GValue *condition,
                                                         GError **error,
                                                         ...);

This is just a convenient function to update values in a table on a given column where the row is fitting the given condition.

The SQL command is like: UPDATE INTO table_name SET column1 = new_value1, column2 = new_value2 ... WHERE condition_column_name = condition

cnc :

an opened connection

table_name :

the name of the table where the update will be done

condition_column_name :

the name of the column to used in the WHERE condition clause

condition :

a GValue to used to find the values to be updated; it must correspond with the column's GType

error :

a place to store errors, or NULL

... :

a list of string/GValue pairs where the string is the name of the column to be updated followed by the new GValue to set, finished by NULL

Returns :

TRUE if no error occurred

gda_delete_row_from_table ()

gboolean            gda_delete_row_from_table           (GdaConnection *cnc,
                                                         const gchar *table_name,
                                                         const gchar *condition_column_name,
                                                         const GValue *condition,
                                                         GError **error);

This is just a convenient function to delete the row fitting the given condition from the given table.

condition must be a valid GValue and must correspond with the GType of the column to use in the WHERE clause.

The SQL command is like: DELETE FROM table_name WHERE contition_column_name = condition

cnc :

an opened connection

table_name :

condition_column_name :

the name of the column to used in the WHERE condition clause

condition :

a GValue to used to find the row to be deleted

error :

a place to store errors, or NULL

Returns :

TRUE if no error occurred, and FALSE and set error otherwise

gda_get_default_handler ()

GdaDataHandler*     gda_get_default_handler             (GType for_type);

Obtain a pointer to a GdaDataHandler which can manage GValue values of type for_type

The returned pointer is NULL if there is no default data handler available for the for_type data type

for_type :

a GType type

Returns :

a GdaDataHandler which must not be modified or destroyed.