Re: How to reuse PREPAREd queries in ProC/C++

From: eye <anonymouz_at_xs4all.nl>
Date: Mon, 6 Jan 2003 19:38:05 +0100
Message-ID: <3e19cd0f$0$49104$e4fe514c_at_news.xs4all.nl>


chgman_at_earthlink.net
I have looked into it but can't find a solution. Can you explain a little more about the process that demands e.g. such a solution?
Why open all the cursors and keeping them open? Possibly an array with pointers to functions can help, and one could generate the code for the prepare and for the execute with using clause funtions (hence a pair of functions for every cursor, or even a triplet if considering the close call) with e.g. a shell script. In the functions then the appropriate execsql is called, and you might have this desired set of indexable cursors.
Beste regards,
erik.ykemaREMOVE_at_xs4all.nl
please reply also per email.

"ChgMan" <> wrote in message
news:RKaP9.2718$Oc.335628_at_newsread2.prod.itd.earthlink.net...
> Hi,
>
> I use Release 8.1.6 of ProC/C++.
> I want to reuse PREPAREd statements, i.e. I want to prepare multiple
> statements,
> obtain handles to them, and execute prepared statements when needed.
> The code might look like below:
> --------------------------------------------------------------------------

--

> ------
> EXEC SQL BEGIN DECLARE SECTION
> int statement_id;
> const char sql_statement[1024];
> const char name[128];
> EXEC SQL END DECLARE SECTION
>
> // Following method prepares statement from the string sql_statement.
> // It takes sql_statement as an input parameter and places handle to the
> prepared
> // statement into statement_id, using it as an output variable. We can
store
> // such handles in some container.
> // For the sake of example we can assume that sql_statement has exactly
one
> placeholder, like in
> // "DELETE FROM employee WHERE name = :n";
> void createPreparedStatement() {
> EXEC SQL PREPARE :statement_id FROM :sql_statement; // Incorrect
> }
>
> // Following method executes prepared statement referred by statement_id.
It
> also
> // takes host variable name as an input parameter
> void executePreparedStatement() {
> EXEC SQL EXECUTE :statement_id USING :name; // Incorrect
> }
> ------------------------------------------------------------------
>
> Unfortunately, statement_id cannot be host variable, it must be Oracle
> variable:
>
> EXEC SQL PREPARE STATEMENT_ID FROM :sql_statement; // Correct, but doesn't
> work for me
> EXEC SQL EXECUTE STATEMENT_ID USING :name; // Correct, but doesn't work
for
> me
>
> Can I still achieve my goal using PREPAREd statements or some other
> technique, like
> stored procedures etc.?
>
> Thank you,
> YP
>
>
>
Received on Mon Jan 06 2003 - 19:38:05 CET

Original text of this message