Esempio n. 1
0
/*
 * ---Implementations---
 */
int INGgetCols(INGconn *dbconn, const char *query, bool explicit_commit)
{
/* # line 52 "myingres.sc" */

  int sess_id;
  char *stmt;
/* # line 55 "myingres.sc" */

   IISQLDA *sqlda;
   int number = -1;
   sqlda = (IISQLDA *)malloc(IISQDA_HEAD_SIZE + IISQDA_VAR_SIZE);
   memset(sqlda, 0, (IISQDA_HEAD_SIZE + IISQDA_VAR_SIZE));
   sqlda->sqln = number;
   stmt = bstrdup(query);
/* # line 68 "myingres.sc" */	/* host code */
   /*
    * Switch to the correct default session for this thread.
    */
   sess_id = dbconn->session_id;
/* # line 72 "myingres.sc" */	/* set_sql */
  {
    IILQssSetSqlio(11,(short *)0,1,30,sizeof(sess_id),&sess_id);
  }
/* # line 74 "myingres.sc" */	/* prepare */
  {
    IIsqInit(&sqlca);
    IIsqPrepare(0,(char *)"s1",sqlda,0,stmt);
    if (sqlca.sqlcode < 0)
      goto bail_out;
  }
/* # line 78 "myingres.sc" */	/* host code */
   number = sqlda->sqld;
bail_out:
   /*
    * If explicit_commit is set we commit our work now.
    */
   if (explicit_commit) {
/* # line 85 "myingres.sc" */	/* commit */
  {
    IIsqInit(&sqlca);
    IIxact(3);
  }
/* # line 86 "myingres.sc" */	/* host code */
   }
   /*
    * Switch to no default session for this thread.
    */
/* # line 91 "myingres.sc" */	/* set_sql */
  {
    IILQssSetSqlio(11,(short *)0,1,30,sizeof(-97),(void *)IILQint(-97));
  }
/* # line 92 "myingres.sc" */	/* host code */
   free(stmt);
   free(sqlda);
   return number;
}
Esempio n. 2
0
static inline IISQLDA *INGgetDescriptor(int numCols, const char *query)
{
/* # line 99 "myingres.sc" */

  char *stmt;
/* # line 101 "myingres.sc" */

   int i;
   IISQLDA *sqlda;
   sqlda = (IISQLDA *)malloc(IISQDA_HEAD_SIZE + (numCols * IISQDA_VAR_SIZE));
   memset(sqlda, 0, (IISQDA_HEAD_SIZE + (numCols * IISQDA_VAR_SIZE)));
   sqlda->sqln = numCols;
   stmt = bstrdup(query);
/* # line 112 "myingres.sc" */	/* prepare */
  {
    IIsqInit(&sqlca);
    IIsqPrepare(0,(char *)"s2",sqlda,0,stmt);
  }
/* # line 114 "myingres.sc" */	/* host code */
   for (i = 0; i < sqlda->sqld; ++i) {
      /*
       * Negative type indicates nullable columns, so an indicator
       * is allocated, otherwise it's null
       */
      if (sqlda->sqlvar[i].sqltype > 0) {
         sqlda->sqlvar[i].sqlind = NULL;
      } else {
         sqlda->sqlvar[i].sqlind = (short *)malloc(sizeof(short));
      }
      /*
       * Alloc space for variable like indicated in sqllen
       * for date types sqllen is always 0 -> allocate by type
       */
      switch (abs(sqlda->sqlvar[i].sqltype)) {
      case IISQ_TSW_TYPE:
         sqlda->sqlvar[i].sqldata = (char *)malloc(IISQ_TSW_LEN);
         break;
      case IISQ_TSWO_TYPE:
         sqlda->sqlvar[i].sqldata = (char *)malloc(IISQ_TSWO_LEN);
         break;
      case IISQ_TSTMP_TYPE:
         sqlda->sqlvar[i].sqldata = (char *)malloc(IISQ_TSTMP_LEN);
         break;
      default:
         /*
          * plus one to avoid zero mem allocs
          */
         sqlda->sqlvar[i].sqldata = (char *)malloc(sqlda->sqlvar[i].sqllen + 1);
         break;
      }
   }
   free(stmt);
   return sqlda;
}
Esempio n. 3
0
void
IIpsqPrepare(i4 lang,char *stmt_name,II_LQTYPE_GPTR sqd,
             i4 using_flag,char *query)
{
    IIsqPrepare(lang,stmt_name,sqd,using_flag,query);
}