Subject | Why do I need to describe_bind sqlda before execution? |
---|---|
Author | Jeff Lynn |
Post date | 2006-04-24T17:48:40Z |
Can someone tell me why I need the isc_dsql_describe_bind to execute
the prepared stmt works?
If I comment it out, the test program crashed!
I created the table, with Id set to integer, since there is no
SQL_INTEGER or SQL_INT, I uses SQL_LONG. I even dumped the pSqlda
after the bibd, which is exactly what I entered.
The API Doc stated that if I know the datatype of the parameeer, I
don't need to exeecute the bind. But that is not what I saw.
Thanks for any info resolving this.
jml
LPSTR pszSql = "delete from Staff where id=?";
long id;
isc_dsql_prepare(status, &hTrans, &hStmt, 0, pszSql, 1, NULL);
pSqlda = (XSQLDA *) new char[XSQLDA_LENGTH(1)];
pSqlda->version = 1;
pSqlda->sqln = 1;
pSqlda->sqld = 1;
pSqlda->sqlvar[0].sqldata = (char *)&id;
pSqlda->sqlvar[0].sqltype = SQL_LONG;
isc_dsql_describe_bind(status, &hStmt, 1, pSqlda );
id = 123;
isc_dsql_execute(status, &hTrans, &hStmt, 1, pSqlda);
the prepared stmt works?
If I comment it out, the test program crashed!
I created the table, with Id set to integer, since there is no
SQL_INTEGER or SQL_INT, I uses SQL_LONG. I even dumped the pSqlda
after the bibd, which is exactly what I entered.
The API Doc stated that if I know the datatype of the parameeer, I
don't need to exeecute the bind. But that is not what I saw.
Thanks for any info resolving this.
jml
LPSTR pszSql = "delete from Staff where id=?";
long id;
isc_dsql_prepare(status, &hTrans, &hStmt, 0, pszSql, 1, NULL);
pSqlda = (XSQLDA *) new char[XSQLDA_LENGTH(1)];
pSqlda->version = 1;
pSqlda->sqln = 1;
pSqlda->sqld = 1;
pSqlda->sqlvar[0].sqldata = (char *)&id;
pSqlda->sqlvar[0].sqltype = SQL_LONG;
isc_dsql_describe_bind(status, &hStmt, 1, pSqlda );
id = 123;
isc_dsql_execute(status, &hTrans, &hStmt, 1, pSqlda);