## Executing commands

### Creating commands

It can be made, more or less, as in the old version, using gda_command_new(), but now, this function needs a few parameters and, in this version, you do not link a command to a connection, so you execute a command in a connection as we'll see later. You can see how to create commands and examples about this here.

### Executing non queries

Non queries are queries that do not return data, as insertions, deletions, and so on. The function we use is gda_connection_execute_non_query () and returns the number of affected tuples or -1 in case of error. Here you see an example.

It is better not to execute more than one SQL sentence for each command because the result can be unexpected.

### Executing normal queries

A normal query is a query that return data. This is made as a data model, analogous to GdaRecordset in the old version[5].

As you can see in the following example, the function we use to obtain data from a SQL sentence is gda_connection_execute_single_command () and needs the parameters of non queries. The difference is that now the function returns the data model or NULL in case of error.

As in the case of non queries, you must not use several semicolon-separated sentences, because you have a special function to do this[6], but it is not recommended.

[5] Now you have a GdaRecordset class, but it is not recommended.

[6] gda_connection_execute_command ()