Pro*C PREPARE/EXECUTE help needed

From: EA <appshome_at_geocities.com>
Date: Thu, 13 Jan 2000 13:53:38 +0100
Message-ID: <85khko$moi$1_at_pollux.ip-plus.net>



[Quoted] I've tried to select a single row into host variables using a prepared statement WITHOUT using a cursor (Pro*C/C++: Release 8.0.4.0.0 on Solaris 2.6):

EXEC SQL PREPARE mystatement FROM "SELECT somefield FROM sometable WHERE sometablekey = :mykeyvalue";
EXEC SQL EXECUTE mystatement USING :mykeyvalue INTO :myvar;

I know that exactly one row should be returned (selection by primary key) so I want to avoid the overhead of opening a cursor, fetching, and then closing/freeing the cursor for performance reasons, but the precompiler doesn't seem to like that:

PCC-S-02201, Encountered the symbol "INTO" when expecting one of the following:

; , : ( [ . ++ -- -> indicator,

Strangely enough though, doing the same without preparing the statement first works just fine:

EXEC SQL SELECT somefield INTO :myvar INDICATOR :myvar_ind FROM sometable WHERE sometablekey = :mykeyvalue;

Has anyone managed to do this before? I know this works for other RDBMS's like Informix. In essence, why would I go through the trouble of preparing my sql statements (which are going to be called thousands of times with varying parameters) for performance reasons when I have to open a cursor each time to select a single row?

[Quoted] [Quoted] Any help would be greatly appreciated

Cheers
E. Received on Thu Jan 13 2000 - 13:53:38 CET

Original text of this message