GNOME Data Access manual | |||
---|---|---|---|
<<< Previous Page | Home | Next Page >>> |
Before invoking a query you have to build the structure containing the command and you can do this with gda_command_new ().
The command type we most commonly use is GDA_COMMAND_TYPE_SQL because we will only focus on SQL queries[1]
typedef enum { |
Here you see an example of creating a command:
Non queries are queries that does not return data, only the number of rows affected, as a DELETE or an UPDATE. We use gda_connection_execute_non_query()
gint execute_sql_non_query (GdaConnection *connection, const gchar * buffer) { GdaCommand *command; gint number; command = gda_command_new (buffer, GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS); number = gda_connection_execute_non_query (connection, command, NULL); gda_command_free (command); return (number); } |
Normal queries are queries that return data (data models). You have two ways to do this:
You can use the first way when you want to invoke only a single command. Second way is used to execute several comma-separated sentences. It is recommended to use gda_connection_execute_single_command (). Here you see an example:
[1] | There are other command types, as XMLand so on. |