I'm trying to use an SQL Descriptor to perform dynamic SQL as described in the
ESQL/C manual, and when I try to open a cursor using this method, I am getting
an error -254, "Too many or too few host variables given." Since I use a
"using sql descriptor" clause, the DESCRIBE of the prepared statement should
have automatically provided an appropriate descriptor for the cursor.
I took the example from the book and did something for the stores7 database
(below), which I mailed to Informix five days ago. I got a call back today,
and the last I heard, they got a mix of core dumps and not being able to
connect to the database with this code on a Sun box. However, I suspect the
person helping me is not an ESQL/C maven, since he did not know what to do to
fix my ANSI prototype function declaration. I'm running Online DSA 7.10.UC2
on an NCR 3431.
Has anybody come across anything like this? Thanks for your help!
The following program prints out "4: -254", meaning that an error -254 has
occurred at the fourth tested statement, the OPEN.
#include <stdio.h>
void test(int i)
{
if (SQLCODE)
{
fprintf(stderr, "%d: %d\\n", i, SQLCODE);
exit(1);
}
}
int main()
{
exec sql begin declare section;
char statementText[] =
"select customer_num from customer";
exec sql end declare section;
exec sql database stores7;
test(0);
exec sql prepare statementId from :statementText;
test(1);
exec sql declare cursorId cursor for statementId;
test(2);
exec sql allocate descriptor 'descriptorId';
test(3);
exec sql open cursorId using sql descriptor 'descriptorId';
test(4);
exec sql describe statementId using sql descriptor 'descriptorId';
test(5);
exec sql close cursorId;
test(6);
exec sql free cursorId;
test(7);
exec sql deallocate descriptor 'descriptorId';
test(8);
exec sql free statementId;
test(9);
return(0);
}