First, it will be nice if you could speak in english so as everybody can take advantage of the help, thanks in advance ;)
Then, Sqlb returned format are the following :
Say that you have declared your result structure as :
tab_t my_result;
and the return value of the Sqlbexec2 function as :
int retv;
then here are the differents possibility :
-> if retv < 0 then every fields of my_result is NULL or 0 except my_result.erreur that hold the error string.
-> if retv = 0, then you have executed a query that has affected rows but returned no data (like insert/delete/update), and every fields of my_result is NULL or 0 execpt my_result.tab_affected that hold the number of affected rows
-> if retv = 2, then you have executed a query that has'nt affected any rows and returned no data so every fields of my_result is NULL or 0.
-> and finally if retv = 1, you have executed a query that has returned some data.
if it was a select so you have :
my_result.tab_affected = 0
my_result.tab_elm hold the number of fields
my_result.tab_row hold the number of rows
my_result.name_cols[my_result.tab_elm] contains the field names
my_result.tab[my_result.tab_row][my_result.tab_elm] hold the data
and if it was an insert/update/delete/call with ouput vars or returning clauses, you must have :
my_result.tab_affected hold the number of affected rows
my_result.tab_elm hold the number of fields
my_result.tab_row = 1
my_result.name_cols[my_result.tab_elm] contains the field name or the ouput vars names my_result.tab[1][my_result.tab_elm] hold the data for each field
Notice :
- Only Oracle8i and PostgreSQL support the returning clauses
- Oracle8i returning clauses syntax is :
insert into ... returning id into :id_var; // then the field name will be ":id_var"
- PostgreSQL returning clauses syntax is :
insert into ... returning id; // then the field name will be "id"
- Oracle8i support call of procedure with output vars, here is the syntax :
call my_proc ("val1", "val2", :retval1, :retval2); // then the fields names will be ":retval1" and ":retval2".
Hope that will help you,
GrumZ
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Serait il possible d'avoir des informations sur les formats de retour du sqlb selon les requetes sql (insert, select ...).
Merci d'avance
Hello,
First, it will be nice if you could speak in english so as everybody can take advantage of the help, thanks in advance ;)
Then, Sqlb returned format are the following :
Say that you have declared your result structure as :
tab_t my_result;
and the return value of the Sqlbexec2 function as :
int retv;
then here are the differents possibility :
-> if retv < 0 then every fields of my_result is NULL or 0 except my_result.erreur that hold the error string.
-> if retv = 0, then you have executed a query that has affected rows but returned no data (like insert/delete/update), and every fields of my_result is NULL or 0 execpt my_result.tab_affected that hold the number of affected rows
-> if retv = 2, then you have executed a query that has'nt affected any rows and returned no data so every fields of my_result is NULL or 0.
-> and finally if retv = 1, you have executed a query that has returned some data.
if it was a select so you have :
my_result.tab_affected = 0
my_result.tab_elm hold the number of fields
my_result.tab_row hold the number of rows
my_result.name_cols[my_result.tab_elm] contains the field names
my_result.tab[my_result.tab_row][my_result.tab_elm] hold the data
and if it was an insert/update/delete/call with ouput vars or returning clauses, you must have :
my_result.tab_affected hold the number of affected rows
my_result.tab_elm hold the number of fields
my_result.tab_row = 1
my_result.name_cols[my_result.tab_elm] contains the field name or the ouput vars names my_result.tab[1][my_result.tab_elm] hold the data for each field
Notice :
- Only Oracle8i and PostgreSQL support the returning clauses
- Oracle8i returning clauses syntax is :
insert into ... returning id into :id_var; // then the field name will be ":id_var"
- PostgreSQL returning clauses syntax is :
insert into ... returning id; // then the field name will be "id"
- Oracle8i support call of procedure with output vars, here is the syntax :
call my_proc ("val1", "val2", :retval1, :retval2); // then the fields names will be ":retval1" and ":retval2".
Hope that will help you,
GrumZ