Re: Pro*C and Oracle 6 How to read Long type?
Date: 3 Feb 1995 20:47:31 GMT
Message-ID: <3gu4p3$cgm_at_homer.alpha.net>
B.LAPA (etjr_at_ci.ua.pt) wrote:
> Hi,
> Can anyone tell me how to retrieve a LONG datatype using Pro*C?
> The data i'll read will be chars.
> Thanks for any help
If you know the max size and can afford a static memory allocation
use a char array to retrieve the value. If not then you
should probably have another column which holds the length of the
long column.
so your table def should be
...
LNG_LEN NUMBER(x)
LNG_COL LONG
...
Then in PROC
long sql_lng_len;
char* sql_lng_col;
to use it
EXEC SQL
select ...., LNG_LEN, ..., rowid, ... /* not lng_col */ into ...., :sql_lng_len,.,:sql_rowid, ... from ... where ... ;
sql_lng_col = malloc ( sql_lng_len + 1 ); memset ( sql_lng_col, 'A', sql_lng_len ); sql_lng_col [sql_lng_col] = '\0'; /* because pro c uses strlen to
see how much to fetch. If you have a char array it would use sizeof */
EXEC SQL
select LNG_COL
into :sql_lng_col
from ...
where rowid = :sql_rowid;
hope this helps.
-- ************************************************************** * Saad Ahmad * * E-Mail: sahmad_at_mfa.com * **************************************************************Received on Fri Feb 03 1995 - 21:47:31 CET