Subject Re: passing NULL using api
Author blahclayton
Here is more info as requested:-

I prepare the following statement :-

UPDATE DATA_IN SET DATA_TEXT = ? WHERE Id = 1
where DATA_TEXT is a varchar(50) and Id is an integer

isc_erro_code = 335544569 (status[1]where status is a
ISC_STATUS_ARRAY returned from executing the statement).

I use Visual Studio 6.0 on windows and KDevlop 3.0 (uses gcc
compiler) on linux.

Here is what I actually do (if need more let me know):

start_transaction
allocate_statement
prepare_statement

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 = 0;
sqlda->sqlvar[i].sqldata = text;

}
else
{
sqlda->sqlvar[i].sqllen = 0;
nullid = -1;
}
// sets up each parameter
sqlda->sqlvar[i].sqltype = SQL_TEXT;
sqlda->sqlvar[i].sqlind = &nullid;
}

execute statement passing the sqlda created above
commit statement



Some example code that does work using example.fdb on linux will be
useful so I can prove it is a compiler problem.

Thanks for you help
Nina


--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> At 07:27 AM 25/08/2004 +0000, you wrote:
> >I have posted this issue before with little response and really
need
> >a solution as any help would be much appreciated.
> >
> >I have been using the firebird api (firebird 1.50 CS) to pass
> >input parameters to some statements. When I try and pass NULL as a
> >input parameter I get an SQL error (-804 - An
> >error was found in application input parameters for the SQL
> >statement!!) error on Linux.
> >
> >Has anybody come across the same problem?
>
> An -804 error to happen is caused by passing the wrong number of
> parameters, or by passing values of an unexpected data type, or by
passing
> parameters to an unprepared statement.
>
> What is the application that is giving you this error message? The
SQL
> code is a Firebird high-level error code, but the error message
isn't a
> Firebird one.
>
>
> >Is there a work around?
>
> You haven't provided enough information yet to pinpoint the
problem, let
> alone provide a solution. Things that would help to get closer to
it:
> 1) the declaration part of the stored procedure
> 2) the actual statement as presented to the API
> 3) the 9-digit isc error code that is returned when the exception
occurs
> 4) the compilers you used on Windows and Linux, respectively
>
>
> >Does anybody have example code of passing NULL as an input
parameter
> >that works on Linux ?
>
> The API is platform-neutral. If your source code compiled and
worked as
> expected on Windows but caused an exception condition when compiled
and run
> on Linux, it would indicate some discrepancy between the compilers,
> wouldn't it?
>
> > I am probably missing the obvious solution as I cannot believe
someone has
> > not tried to do this before.
>
> People pass nulls in parameters all the time. Track back in the
archive to
> the examples Dmitry Sibiryakov and Ivan Prenosil gave you a few
days ago.
> Show us some code..
>
> ./heLen