I am using the C/C++ precompiler of SAP DB 7.3.0.34 and want
to store binary data in LONG (BYTE) columns.
I have the following ESQL/C code snippet, there are no database errors
at runtime, but the data isn't stored. What am I doing wrong ?

int Update (char * sqlstmt, tparam param[], int nparam) {
  EXEC SQL BEGIN DECLARE SECTION;
    char * stmt;
    char stmtupd[8];
  EXEC SQL END DECLARE SECTION;
  sqlvartype *ha;
  int longcols=0;

  stmt = sqlstmt;
  EXEC SQL PREPARE stmtupd FROM  :stmt;
  if (sqlca.sqlcode!=0){return 1;}

  EXEC SQL DESCRIBE stmtupd;
  if (sqlca.sqlcode!=0){return 1;}

  for (i=0;i<nparam;i++){
    ha = &sqlda.sqlvar[i];
    if (ha->col.colislong) {
      SQLLongDesc *ldesc = (SQLLongDesc *)alloca(sizeof(SQLLongDesc));
      ldesc->szBuf = param[i].buf;
      ldesc->cbBufMax = param[i].size;
      ldesc->cbBufLen = param[i].size;

      ha->hostvartype=sqlvlongdesc;
      ha->hostvaraddr=ldesc;
      ha->hostcolsize = sizeof (SQLLongDesc);
      ha->collength = sizeof (SQLLongDesc);

      longcols = 1;
    } else {
      ...
    }
  }

  EXEC SQL EXECUTE stmtupd USING DESCRIPTOR;
  if (sqlca.sqlcode!=0 && sqlca.sqlcode!=100) {return 1;}

  if (longcols) {
    EXEC SQL PUTVAL stmtupd USING DESCRIPTOR;
    if (sqlca.sqlcode!=0 && sqlca.sqlcode!=100){return 1;}
  }

  return 0;
}


Regards,

CTB
-- 
_______
\o/|\o/   Claus-Thomas Buhl
   |      Diplom-Informatiker
\_____/   mailto:[EMAIL PROTECTED]

H.E.I. GmbH | Wimpfener Strasse 23 | D-68259 Mannheim
Fon: +49-(0)621-795141 | Fax: +49-(0)621-795161 | mailto:[EMAIL PROTECTED]
http://www.h-e-i.de && http://www.hei.biz && http://www.radpage.com
_______________________________________________
sapdb.general mailing list
[EMAIL PROTECTED]
http://listserv.sap.com/mailman/listinfo/sapdb.general

Reply via email to