Selecting LONG datatype using Pro*C

From: William J. Bene <wjb_at_cscsun2.larc.nasa.gov>
Date: Thu, 2 Jul 1992 11:47:09 GMT
Message-ID: <1992Jul2.114709.8729_at_news.larc.nasa.gov>


When selecting LONG datatypes from a remote ORACLE database I keep getting one more character added to the end of the strings. The documentation I have says very little on how to retrieve LONG datatypes so I used the same method I am using to retrieve CHAR datatypes. Here is a simplified blurb of the code:

EXEC SQL BEGIN DECLARE SECTION;

    VARCHAR      mylong[5000];
	short        imylong;

EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER NOT FOUND GOTO :NotFound; EXEC SQL WHENEVER SQLERROR GOTO :SQLError;

EXEC SQL SELECT LONGSTR INTO :mylong:imylong FROM LONGTABLE;

if (imylong == -1)

        /* then it is null */
else if (imylong == 0) {

    strncpy(myappvar, mylong.arr, mylong.len);     myappvar[mylong.len] = '\0';
    }
else

    /* the return value was truncated */

Using a debugger, the indicator variable 'imylong' is zero, so there was no problem getting the value. However, 'mylong.len' is always one larger than the actual length of my string. The added character is an ASCII 11. I have also ran into this using HyperSQL one other time, but have been unable to duplicate the error.

I am using SQL*Net V1.5 and the Pro*C precompiler from ORACLE for the Macintosh V2.0. Any thoughts or ideas would be highly appreciated.

Thanks, Will



William J. Bene
Computer Sciences Corporation
wjb_at_cscsun2.larc.nasa.gov Received on Thu Jul 02 1992 - 13:47:09 CEST

Original text of this message