Takahashi-san, > I tried as follows. > ... > Unfortunately, this does not work. > ECPGst_execute seems good, but prepare statement is the same as my > first post.
Ah right, my bad. The workaround should have been: EXEC SQL PREPARE test_prep from "SELECT id from test_table where id = $1"; EXEC SQL EXECUTE test_prep using 2; > It fails with "PostgreSQL error : -202[too few arguments on line > 16]". > > This error is caused by following source code. > ... > I think next_insert() should ignore "$n" in the case of SQL statement > PREPARE. Actually I am not so sure. > In addition, we should fix following, right? > > (1) > As Matsumura-san wrote, ECPG should not produce '"' for SQL statement > PREPARE. Why's that? > (2) > ECPG should produce argument for execute statement such as "EXEC SQL > EXECUTE test_prep (2);" Correct. As for the PREPARE statement itself, could you try the attached small patch please. This seems to create the correct ECPGPrepare call, but I have not yet tested it for many use cases. Thanks. Michael -- Michael Meskes Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) Meskes at (Debian|Postgresql) dot Org Jabber: michael at xmpp dot meskes dot org VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL
diff --git a/src/interfaces/ecpg/preproc/ecpg.addons b/src/interfaces/ecpg/preproc/ecpg.addons index e8052819b0..bfd76960a2 100644 --- a/src/interfaces/ecpg/preproc/ecpg.addons +++ b/src/interfaces/ecpg/preproc/ecpg.addons @@ -22,12 +22,7 @@ ECPG: stmtUpdateStmt block ECPG: stmtExecuteStmt block { output_statement($1, 1, ECPGst_execute); } ECPG: stmtPrepareStmt block - { - if ($1.type == NULL || strlen($1.type) == 0) - output_prepare_statement($1.name, $1.stmt); - else - output_statement(cat_str(5, mm_strdup("prepare"), $1.name, $1.type, mm_strdup("as"), $1.stmt), 0, ECPGst_normal); - } + { output_prepare_statement($1.name, $1.stmt); } ECPG: stmtTransactionStmt block { fprintf(base_yyout, "{ ECPGtrans(__LINE__, %s, \"%s\");", connection ? connection : "NULL", $1);