char *stmt;
/* # line 55 "myingres.sc" */
+ short number = -1;
IISQLDA *sqlda;
sqlda = (IISQLDA *)malloc(IISQDA_HEAD_SIZE + IISQDA_VAR_SIZE);
memset(sqlda, 0, (IISQDA_HEAD_SIZE + IISQDA_VAR_SIZE));
- short number = -1;
sqlda->sqln = number;
stmt = bstrdup(query);
/*
* Switch to the correct default session for this thread.
*/
sess_id = dbconn->session_id;
-/* # line 70 "myingres.sc" */ /* set_sql */
+/* # line 71 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
}
-/* # line 74 "myingres.sc" */ /* prepare */
+/* # line 75 "myingres.sc" */ /* prepare */
{
IIsqInit(&sqlca);
- IIsqPrepare(0,(char *)"s1",sqlda,0,stmt);
+ IIsqPrepare(0,(char *)"s1",(char *)0,0,stmt);
if (sqlca.sqlcode < 0)
goto bail_out;
}
-/* # line 78 "myingres.sc" */ /* host code */
+/* # line 76 "myingres.sc" */ /* describe */
+ {
+ IIsqInit(&sqlca);
+ IIsqDescribe(0,(char *)"s1",sqlda,0);
+ if (sqlca.sqlcode < 0)
+ goto bail_out;
+ }
+/* # line 80 "myingres.sc" */ /* host code */
number = sqlda->sqld;
/*
* If we are not in a transaction we commit our work now.
*/
if (!transaction) {
-/* # line 84 "myingres.sc" */ /* commit */
+/* # line 86 "myingres.sc" */ /* commit */
{
IIsqInit(&sqlca);
IIxact(3);
}
-/* # line 85 "myingres.sc" */ /* host code */
+/* # line 87 "myingres.sc" */ /* host code */
}
bail_out:
/*
* Switch to no default session for this thread.
*/
-/* # line 91 "myingres.sc" */ /* set_sql */
+/* # line 93 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
}
-/* # line 92 "myingres.sc" */ /* host code */
+/* # line 94 "myingres.sc" */ /* host code */
free(stmt);
free(sqlda);
return number;
}
static inline IISQLDA *INGgetDescriptor(short numCols, const char *query)
{
-/* # line 99 "myingres.sc" */
+/* # line 101 "myingres.sc" */
char *stmt;
-/* # line 101 "myingres.sc" */
+/* # line 103 "myingres.sc" */
int i;
IISQLDA *sqlda;
memset(sqlda, 0, (IISQDA_HEAD_SIZE + (numCols * IISQDA_VAR_SIZE)));
sqlda->sqln = numCols;
stmt = bstrdup(query);
-/* # line 112 "myingres.sc" */ /* prepare */
+/* # line 115 "myingres.sc" */ /* prepare */
{
IIsqInit(&sqlca);
IIsqPrepare(0,(char *)"s2",sqlda,0,stmt);
}
-/* # line 114 "myingres.sc" */ /* host code */
+/* # line 117 "myingres.sc" */ /* host code */
for (i = 0; i < sqlda->sqld; ++i) {
/*
* Negative type indicates nullable columns, so an indicator
IISQLDA *desc;
int linecount = -1;
desc = ing_res->sqlda;
-/* # line 368 "myingres.sc" */ /* open */
+/* # line 371 "myingres.sc" */ /* open */
{
IIsqInit(&sqlca);
- IIcsOpen((char *)"c2",14864,14190);
+ IIcsOpen((char *)"c2",11858,14584);
IIwritio(0,(short *)0,1,32,0,(char *)"s2");
- IIcsQuery((char *)"c2",14864,14190);
+ IIcsQuery((char *)"c2",11858,14584);
if (sqlca.sqlcode < 0)
goto bail_out;
}
-/* # line 372 "myingres.sc" */ /* host code */
+/* # line 375 "myingres.sc" */ /* host code */
linecount = 0;
do {
-/* # line 374 "myingres.sc" */ /* fetch */
+/* # line 377 "myingres.sc" */ /* fetch */
{
IIsqInit(&sqlca);
- if (IIcsRetScroll((char *)"c2",14864,14190,-1,-1) != 0) {
+ if (IIcsRetScroll((char *)"c2",11858,14584,-1,-1) != 0) {
IIcsDaGet(0,desc);
IIcsERetrieve();
} /* IIcsRetrieve */
}
-/* # line 376 "myingres.sc" */ /* host code */
+/* # line 379 "myingres.sc" */ /* host code */
if (sqlca.sqlcode == 0 || sqlca.sqlcode == -40202) {
/*
* Allocate space for fetched row
row->row_number = linecount++;
}
} while ( (sqlca.sqlcode == 0) || (sqlca.sqlcode == -40202) );
-/* # line 397 "myingres.sc" */ /* close */
+/* # line 400 "myingres.sc" */ /* close */
{
IIsqInit(&sqlca);
- IIcsClose((char *)"c2",14864,14190);
+ IIcsClose((char *)"c2",11858,14584);
}
-/* # line 399 "myingres.sc" */ /* host code */
+/* # line 402 "myingres.sc" */ /* host code */
ing_res->status = ING_COMMAND_OK;
ing_res->num_rows = linecount;
bail_out:
int INGexec(INGconn *dbconn, const char *query, bool transaction)
{
int check;
-/* # line 482 "myingres.sc" */
+/* # line 485 "myingres.sc" */
int sess_id;
int rowcount;
- int errors;
char *stmt;
-/* # line 487 "myingres.sc" */
+/* # line 489 "myingres.sc" */
rowcount = -1;
stmt = bstrdup(query);
* Switch to the correct default session for this thread.
*/
sess_id = dbconn->session_id;
-/* # line 496 "myingres.sc" */ /* set_sql */
+/* # line 498 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
}
-/* # line 500 "myingres.sc" */ /* execute */
+/* # line 502 "myingres.sc" */ /* execute */
{
IIsqInit(&sqlca);
IIsqExImmed(stmt);
if (sqlca.sqlcode < 0)
goto bail_out;
}
-/* # line 501 "myingres.sc" */ /* inquire_ingres */
+/* # line 503 "myingres.sc" */ /* inquire_ingres */
{
IILQisInqSqlio((short *)0,1,30,sizeof(rowcount),&rowcount,8);
}
-/* # line 503 "myingres.sc" */ /* host code */
- /*
- * See if the negative rowcount is due to errors.
- */
- if (rowcount < 0) {
-/* # line 507 "myingres.sc" */ /* inquire_ingres */
- {
- IILQisInqSqlio((short *)0,1,30,sizeof(errors),&errors,0);
- }
-/* # line 509 "myingres.sc" */ /* host code */
- /*
- * If the number of errors is 0 we got a negative rowcount
- * because the statement we executed doesn't give a rowcount back.
- * Lets pretend we have a rowcount of 1 then.
- */
- if (errors == 0) {
- rowcount = 1;
- }
- }
-/* # line 521 "myingres.sc" */ /* host code */
+/* # line 507 "myingres.sc" */ /* host code */
/*
* If we are not in a transaction we commit our work now.
*/
if (!transaction) {
-/* # line 525 "myingres.sc" */ /* commit */
+/* # line 511 "myingres.sc" */ /* commit */
{
IIsqInit(&sqlca);
IIxact(3);
}
-/* # line 526 "myingres.sc" */ /* host code */
+/* # line 512 "myingres.sc" */ /* host code */
}
bail_out:
/*
* Switch to no default session for this thread.
*/
-/* # line 532 "myingres.sc" */ /* set_sql */
+/* # line 518 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
}
-/* # line 533 "myingres.sc" */ /* host code */
+/* # line 519 "myingres.sc" */ /* host code */
free(stmt);
return rowcount;
}
INGresult *res = NULL;
int rows = -1;
int cols = INGgetCols(dbconn, query, transaction);
-/* # line 546 "myingres.sc" */
+/* # line 532 "myingres.sc" */
int sess_id;
-/* # line 548 "myingres.sc" */
+/* # line 534 "myingres.sc" */
/*
* Switch to the correct default session for this thread.
*/
sess_id = dbconn->session_id;
-/* # line 554 "myingres.sc" */ /* set_sql */
+/* # line 540 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
}
-/* # line 556 "myingres.sc" */ /* host code */
+/* # line 542 "myingres.sc" */ /* host code */
desc = INGgetDescriptor(cols, query);
if (!desc) {
goto bail_out;
* If we are not in a transaction we commit our work now.
*/
if (!transaction) {
-/* # line 580 "myingres.sc" */ /* commit */
+/* # line 566 "myingres.sc" */ /* commit */
{
IIsqInit(&sqlca);
IIxact(3);
}
-/* # line 581 "myingres.sc" */ /* host code */
+/* # line 567 "myingres.sc" */ /* host code */
}
/*
* Switch to no default session for this thread.
*/
-/* # line 585 "myingres.sc" */ /* set_sql */
+/* # line 571 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
}
-/* # line 586 "myingres.sc" */ /* host code */
+/* # line 572 "myingres.sc" */ /* host code */
return res;
}
void INGclear(INGresult *res)
}
void INGcommit(const INGconn *dbconn)
{
-/* # line 601 "myingres.sc" */
+/* # line 587 "myingres.sc" */
int sess_id;
-/* # line 603 "myingres.sc" */
+/* # line 589 "myingres.sc" */
if (dbconn != NULL) {
sess_id = dbconn->session_id;
-/* # line 607 "myingres.sc" */ /* disconnect */
+/* # line 593 "myingres.sc" */ /* disconnect */
{
IIsqInit(&sqlca);
IILQsidSessID(sess_id);
IIsqDisconnect();
}
-/* # line 609 "myingres.sc" */ /* host code */
+/* # line 595 "myingres.sc" */ /* host code */
/*
* Commit our work.
*/
-/* # line 612 "myingres.sc" */ /* commit */
+/* # line 598 "myingres.sc" */ /* commit */
{
IIsqInit(&sqlca);
IIxact(3);
}
-/* # line 614 "myingres.sc" */ /* host code */
+/* # line 600 "myingres.sc" */ /* host code */
/*
* Switch to no default session for this thread.
*/
-/* # line 617 "myingres.sc" */ /* set_sql */
+/* # line 603 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
}
-/* # line 618 "myingres.sc" */ /* host code */
+/* # line 604 "myingres.sc" */ /* host code */
}
}
INGconn *INGconnectDB(char *dbname, char *user, char *passwd, int session_id)
{
-/* # line 623 "myingres.sc" */
+/* # line 609 "myingres.sc" */
char ingdbname[24];
char ingdbuser[32];
char ingdbpasswd[32];
int sess_id;
-/* # line 628 "myingres.sc" */
+/* # line 614 "myingres.sc" */
INGconn *dbconn;
if (dbname == NULL || strlen(dbname) == 0) {
}
sess_id = session_id;
bstrncpy(ingdbname, dbname, sizeof(ingdbname));
-/* # line 640 "myingres.sc" */ /* host code */
+/* # line 626 "myingres.sc" */ /* host code */
if (user != NULL) {
bstrncpy(ingdbuser, user, sizeof(ingdbuser));
if (passwd != NULL) {
} else {
memset(ingdbpasswd, 0, sizeof(ingdbpasswd));
}
-/* # line 647 "myingres.sc" */ /* connect */
+/* # line 633 "myingres.sc" */ /* connect */
{
IIsqInit(&sqlca);
IILQsidSessID(sess_id);
if (sqlca.sqlcode < 0)
goto bail_out;
}
-/* # line 652 "myingres.sc" */ /* host code */
+/* # line 638 "myingres.sc" */ /* host code */
} else {
-/* # line 653 "myingres.sc" */ /* connect */
+/* # line 639 "myingres.sc" */ /* connect */
{
IIsqInit(&sqlca);
IILQsidSessID(sess_id);
if (sqlca.sqlcode < 0)
goto bail_out;
}
-/* # line 656 "myingres.sc" */ /* host code */
+/* # line 642 "myingres.sc" */ /* host code */
}
-/* # line 660 "myingres.sc" */ /* host code */
+/* # line 646 "myingres.sc" */ /* host code */
dbconn = (INGconn *)malloc(sizeof(INGconn));
memset(dbconn, 0, sizeof(INGconn));
bstrncpy(dbconn->dbname, ingdbname, sizeof(dbconn->dbname));
/*
* Switch to no default session for this thread undo default settings from SQL CONNECT.
*/
-/* # line 673 "myingres.sc" */ /* set_sql */
+/* # line 659 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
}
-/* # line 675 "myingres.sc" */ /* host code */
+/* # line 661 "myingres.sc" */ /* host code */
bail_out:
return dbconn;
}
* system Specifies the general timeout default for the INGRES system
*
*/
-/* # line 741 "myingres.sc" */
+/* # line 727 "myingres.sc" */
int sess_id;
-/* # line 743 "myingres.sc" */
+/* # line 729 "myingres.sc" */
if (dbconn != NULL) {
sess_id = dbconn->session_id;
/*
* Switch to the correct default session for this thread.
*/
-/* # line 750 "myingres.sc" */ /* set_sql */
+/* # line 736 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
}
-/* # line 752 "myingres.sc" */ /* set */
+/* # line 738 "myingres.sc" */ /* set */
{
IIsqInit(&sqlca);
IIwritio(0,(short *)0,1,32,0,(char *)
"set LOCKMODE session where level=system, readlock=nolock");
IIsyncup((char *)0,0);
}
-/* # line 754 "myingres.sc" */ /* host code */
+/* # line 740 "myingres.sc" */ /* host code */
/*
* Switch to no default session for this thread.
*/
-/* # line 757 "myingres.sc" */ /* set_sql */
+/* # line 743 "myingres.sc" */ /* set_sql */
{
IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
}
-/* # line 758 "myingres.sc" */ /* host code */
+/* # line 744 "myingres.sc" */ /* host code */
}
}
void INGdisconnectDB(INGconn *dbconn)
{
-/* # line 763 "myingres.sc" */
+/* # line 749 "myingres.sc" */
int sess_id;
-/* # line 765 "myingres.sc" */
+/* # line 751 "myingres.sc" */
if (dbconn != NULL) {
sess_id = dbconn->session_id;
-/* # line 769 "myingres.sc" */ /* disconnect */
+/* # line 755 "myingres.sc" */ /* disconnect */
{
IIsqInit(&sqlca);
IILQsidSessID(sess_id);
IIsqDisconnect();
}
-/* # line 771 "myingres.sc" */ /* host code */
+/* # line 757 "myingres.sc" */ /* host code */
free(dbconn->msg);
free(dbconn);
}
}
char *INGerrorMessage(const INGconn *dbconn)
{
-/* # line 778 "myingres.sc" */
+/* # line 764 "myingres.sc" */
char errbuf[256];
-/* # line 780 "myingres.sc" */
+/* # line 766 "myingres.sc" */
-/* # line 782 "myingres.sc" */ /* inquire_ingres */
+/* # line 768 "myingres.sc" */ /* inquire_ingres */
{
IILQisInqSqlio((short *)0,1,32,255,errbuf,63);
}
-/* # line 783 "myingres.sc" */ /* host code */
+/* # line 769 "myingres.sc" */ /* host code */
strncpy(dbconn->msg, errbuf, sizeof(dbconn->msg));
return dbconn->msg;
}
int INGputCopyEnd(INGconn *dbconn, const char *errormsg);
int INGputCopyData(INGconn *dbconn, const char *buffer, int nbytes);
*/
-/* # line 797 "myingres.sc" */
+/* # line 783 "myingres.sc" */
#endif