Executing a query | |||||||||||
If you want to execute a query you will need to specify
a handle ( tkeyuser which contains the following
data:
In this example, we want to execute a query which returns all the rows for the
fields
SELECT iduser,dtname FROM tkeydata ORDER BY iduser
If you execute this statement you would get two rows each with two columns of data. This data has to be stored somewhere so that your programm can actually use it, so you need to define a variable for each of the columns. So you need to bind a column to variable in your program. Binding a variable automatically stores the data of the column in the variable when you retrieve a result row from the connection. It is important that your variables match the type of the column in the table within the database.
So we need to bin column #1 to a variable of type
SQLHSTMT V_OD_hstmt; // Handle for a statement
Now we can bind the variables:
Yes you should check for the return code of the function call. I'm to lazy to code it here once again :( Now we can execute the query by callingSQLExecDirect :
|