Subject Re: [firebird-support] describe_bind
Author Dimitry Sibiryakov
On 19 Aug 2004 at 10:20, blahclayton wrote:

>I am using isc_dsql_describe_bind() to bind all parameter as a char*

You use it wrongly. describe_bind does not bind parameters. It
_describes_ them.

> unsigned int nSize = 1;
> XSQLDA* sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH(nSize));;
> sqlda->version = 1;
> sqlda->sqld = nSize;
> sqlda->sqln = nSize;
> char* text = "test";
> for(unsigned int i = 0; i < nSize; i++)
> {
> printf("%s\n",aParam->Item(i));
> // sets up each parameter
> sqlda->sqlvar[i].sqldata = text;
> sqlda->sqlvar[i].sqltype = SQL_VARYING;

BTW, change SQL_VARYING to SQL_TEXT.

> sqlda->sqlvar[i].sqllen = strlen(text);
> sqlda->sqlvar[i].sqlind = 0;
>
> }

You must either set up SQLDA by hands as above or ask server to do
it as below. But not both.

> if(isc_dsql_describe_bind(m_status, &stmt, nSize, sqlda))
> {
> ThrowsError();
> }
>
>I however get an error -804 - An error was found in application input
>parameters for the SQL statement!!
>
>What am I am doing wrong? Why does this not work?

You don't understand what is internal representation of VARCHAR.
Look at PARAM_VARY struct. VARCHAR has a short int actual length in
the beginning.

>I was hoping to pass all paramater types as char*

In this case you have to use SQL_TEXT type ...and pray that server
can coerce you text into needed form. Personally, I prefer to give to
server what it wants.

>can I do this? can anyone give me tips/ example code? What do I do I
>do if I need to pass 'null'?

Set null indicator to -1.

SY, Dimitry Sibiryakov.