Subject | Re: describe_bind |
---|---|
Author | blahclayton |
Post date | 2004-08-19T14:01:07Z |
Thankyou that has sorted out most of my problems.
However when I set the null indicator (sqlda->sqlvar[i].sqlind) to -
1, i get the error again (-804 - An error was found in application
input parameters for the SQL statement!!).
e.g.
unsigned int nSize = 1;
short nullid = 0;
XSQLDA* sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH(nSize));;
sqlda->version = 1;
sqlda->sqld = nSize;
sqlda->sqln = nSize;
char* text = NULL;
for(unsigned int i = 0; i < nSize; i++)
{
if(text != NULL)
{
nullid = -1;
sqlda->sqlvar[i].sqllen = strlen(text);
}
// sets up each parameter
sqlda->sqlvar[i].sqldata = text;
sqlda->sqlvar[i].sqltype = SQL_TEXT;
sqlda->sqlvar[i].sqlind = &nullid;
}
am I doing something wrong?
If I set text to a value e.g text = "test" it works fine!!
Nina
--- In firebird-support@yahoogroups.com, "Dimitry Sibiryakov"
<SD@t...> wrote:
However when I set the null indicator (sqlda->sqlvar[i].sqlind) to -
1, i get the error again (-804 - An error was found in application
input parameters for the SQL statement!!).
e.g.
unsigned int nSize = 1;
short nullid = 0;
XSQLDA* sqlda = (XSQLDA *) malloc(XSQLDA_LENGTH(nSize));;
sqlda->version = 1;
sqlda->sqld = nSize;
sqlda->sqln = nSize;
char* text = NULL;
for(unsigned int i = 0; i < nSize; i++)
{
if(text != NULL)
{
nullid = -1;
sqlda->sqlvar[i].sqllen = strlen(text);
}
// sets up each parameter
sqlda->sqlvar[i].sqldata = text;
sqlda->sqlvar[i].sqltype = SQL_TEXT;
sqlda->sqlvar[i].sqlind = &nullid;
}
am I doing something wrong?
If I set text to a value e.g text = "test" it works fine!!
Nina
--- In firebird-support@yahoogroups.com, "Dimitry Sibiryakov"
<SD@t...> wrote:
> On 19 Aug 2004 at 10:20, blahclayton wrote:char*
>
> >I am using isc_dsql_describe_bind() to bind all parameter as a
>do
> 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
> it as below. But not both.input
>
> > if(isc_dsql_describe_bind(m_status, &stmt, nSize, sqlda))
> > {
> > ThrowsError();
> > }
> >
> >I however get an error -804 - An error was found in application
> >parameters for the SQL statement!!server
> >
> >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
> can coerce you text into needed form. Personally, I prefer to giveto
> server what it wants.I
>
> >can I do this? can anyone give me tips/ example code? What do I do
> >do if I need to pass 'null'?
>
> Set null indicator to -1.
>
> SY, Dimitry Sibiryakov.