Pro*C: result codes from dynamic SQL

From: Kyler Laird <laird_at_pasture.ecn.purdue.edu>
Date: 1995/12/24
Message-ID: <4bk270$666_at_mozo.cc.purdue.edu>#1/1


I'm modifying a CGI app to use dynamic SQL (because I need to use a unique temporary table name) and I found that sqlca doesn't appear to get updated anymore.

Here's what I'm trying to convert:

short is_inlist(char *name) {

    EXEC SQL SELECT name

        FROM temp_entry
        WHERE name like :name;

    if (sqlca.sqlcode == 0)
        return(YES);
    else
        return(NO);

}

"temp_entry" is the problem - it needs to be a variable, so I switched to

	sprintf(sqlstmt, "\
        SELECT name\
            FROM %s\
            WHERE name like :v1\
        ",
        request.temp_table);
	EXEC SQL PREPARE S_is_inlist from :sqlstmt;

and then used

short is_inlist(char *name) {

    EXEC SQL EXECUTE S_is_inlist USING :name;

    if (sqlca.sqlcode == 0)

        return(YES);
    else

        return(NO);
}

Unfortunately, when I do this, sqlca.sqlcode (and even sqlca.sqlerrd[2]) *always* come back 0.

I'm unable to get through to the FAQ right now, but I will check again on it later. I'd greatly appreciate some help with this.

--kyler Received on Sun Dec 24 1995 - 00:00:00 CET

Original text of this message