Subject Question about C-api
Author Yves Glodt
Hello,

I am using ib6 in Linux for a cgi-application, and since C (and so the
C-api) is quite new to me, I have a question that maybe someone can
answer. (I wrote the same app in Delphi, and there it rocks)
These are fragments of my code (I can provide all of it when necessary)

In fact I need two queries in my application, one simple select, and
another select with parameters.
This code-fragment shows the order of the isc_*** calls, and this part
works well. Now the question:

When my structure is filled with the first set of data (see comment), I
need the second query to fill it with the rest.
Where can I hook in with the second query? After isc_commit_transaction
maybe? Which handles have to be initialized before? What would be the
right order of isc_*** calls with multiple queries?
I found no document on http://www.ibphoenix.com related to the C-API.
I think it could be useful for starters if there was some example code
using multiple queries and parameters etc.

Thanks in advance,

Yves Glodt



isc_attach_database(status_vector, strlen(db_name), db_name,
&db_handle, dpb_length, dpb_buffer);
sql_stmt01 = "SELECT IPN,PERS_NAME FROM WT_PERS ORDER BY PERS_NAME";
isc_start_transaction (status_vector, &tr_handle, 1, &db_handle, 0,
NULL);

out_sqlda = (XSQLDA *) malloc (XSQLDA_LENGTH (2));
out_sqlda->version = SQLDA_VERSION1;
out_sqlda->sqln = 2;
out_sqlda->sqld = 2; // number of columns ???

isc_dsql_allocate_statement (status_vector, &db_handle, &stmt_handle);
isc_dsql_prepare (status_vector, &tr_handle, &stmt_handle, 0,
sql_stmt01, 1, out_sqlda); //last var was sqlda

out_sqlda->sqlvar[0].sqldata = &ipn_i;
out_sqlda->sqlvar[0].sqltype = SQL_LONG;
out_sqlda->sqlvar[0].sqlind = NULL;
out_sqlda->sqlvar[1].sqldata = name_s;
out_sqlda->sqlvar[1].sqltype = SQL_TEXT;
out_sqlda->sqlvar[1].sqlind = NULL;

isc_dsql_execute (status_vector, &tr_handle, &stmt_handle, 1, NULL);
//-----------------filling of the structure---------------
while (( SQLCODE = isc_dsql_fetch (status_vector, &stmt_handle, 1,
out_sqlda)) == 0 )
{
number_of_ipn+=1;
whole_month[number_of_ipn].ipn = ipn_i;
sprintf(whole_month[number_of_ipn].name,"<td align=\"LEFT\"
class=\"name\">%s</td>",name_s);
for (j = 1; j <= days_in_month; j++)
{
sprintf(whole_month[number_of_ipn].days[j],"<td
class=\"n\">%i</td>",j);
}
memset(name_s,0,51);
}
if (SQLCODE != 100L)
{
write_html_error(status_vector,"Querying WT_PERS: No more rows left!",
css_file, body_tag, app_path);
return(1);
}

isc_dsql_free_statement (status_vector, &stmt_handle, DSQL_close);
isc_commit_transaction (status_vector, &tr_handle);
isc_detach_database(status_vector, &db_handle);




p.s. I check the status_vector after each isc_***, but took it away in
the mail to save space and increase readability.
--
"...two men say they're Jesus, one of them must be wrong."
- Dire Straits "Industrial Disease" (1982)