[comp.databases] Informix ESQL/C SQLDA-structure problem

vwa@cs.hut.fi (06/26/91)

When storing integer information in the sqlda-structure

	sqlda->sqlvar[i].sqldata = malloc (SIZINT)

and after that executing a prepared INSERT with that structure,
I never get INTEGERS right.  They are always treated as CHARS
somewhere during the EXECUTE. So the result is, that they are
truncated like

	127 -> 0
	-1  -> 255

I suppose, that the definition of the field sqldata as 'char *' 
in the include-file sqlda.h
has something to do with this problem.



	Having spent desparate hours debugging...

	Vesa W

lance@mpd.tandem.com (Lance Hartmann) (06/27/91)

In article <1991Jun26.121056.19420@nntp.hut.fi> vwa@cs.hut.fi writes:
>When storing integer information in the sqlda-structure
>
>	sqlda->sqlvar[i].sqldata = malloc (SIZINT)
>
>and after that executing a prepared INSERT with that structure,
>I never get INTEGERS right.  They are always treated as CHARS
>[REMAINDER DELETED]

Do you have the data type specified correctly (ie. do you have
sqlda->sqlvar[i].sqltype = CINTTYPE)?  Also, don't forget that
you should be using rtypalign() to make sure you're on the
correct boundary for that variable type.  This may be your problem.
Remember that a malloc() doesn't force any kind of boundary alignment.
-- 
Lance G. Hartmann - cs.utexas.edu!devnull!lance (Internet)
-------------------------------------------------------------------------------
DISCLAIMER:  All opinions/actions expressed herein reflect those of my VERY OWN
and shall NOT bear any reflection upon Tandem or anyone else for that matter.

das@trac2000.ueci.com (David Snyder) (06/28/91)

In article <1991Jun26.121056.19420@nntp.hut.fi>, vwa@cs.hut.fi writes:
> When storing integer information in the sqlda-structure
> 
> 	sqlda->sqlvar[i].sqldata = malloc (SIZINT)
> 
> and after that executing a prepared INSERT with that structure,
> I never get INTEGERS right.
>
Personnally, I never use "integer" in any of my ESQL/C programs.  The
"integer" data type is ambiguous across some platforms.  I find it
better to use "short" or "long" data types.

I have a good example of how to use the SQLDA structure if your interested.

DAS
-- 
David A. Snyder @ UE&C - Catalytic in Philadelphia, PA

UUCP:  ..!uunet!trac2000!das     INTERNET:  das@trac2000.ueci.com