SQL statement PREPARE does not work in ECPG
| От | Takahashi, Ryohei |
|---|---|
| Тема | SQL statement PREPARE does not work in ECPG |
| Дата | |
| Msg-id | EE586BE92A4AFB45B03310C2A0C0565D6D37FDFC@G01JPEXMBKW03 обсуждение исходный текст |
| Ответы |
RE: SQL statement PREPARE does not work in ECPG
|
| Список | pgsql-hackers |
Hi,
In the PostgreSQL Documentation, both ECPG PREPARE and SQL statement PREPARE can be used in ECPG [1].
However, SQL statement PREPARE does not work.
I wrote the source code as follows.
<test_app.pgc>
============================
EXEC SQL PREPARE test_prep (int) AS SELECT id from test_table where id = $1;
EXEC SQL EXECUTE test_prep (2);
============================
PostgreSQL 11.2 ECPG produced following code.
<test_app.c>
============================
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "prepare \"test_prep\" ( int ) as \" select id from test_table where
id= $1 \"", ECPGt_EOIT, ECPGt_EORT);
#line 16 "test_app.pgc"
if (sqlca.sqlcode < 0) error_exit ( );}
#line 16 "test_app.pgc"
{ ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_execute, "test_prep", ECPGt_EOIT, ECPGt_EORT);
#line 17 "test_app.pgc"
if (sqlca.sqlcode < 0) error_exit ( );}
#line 17 "test_app.pgc"
============================
There are following problems.
(1)
When I run this program, it failed with "PostgreSQL error : -202[too few arguments on line 16]".
The reason is ECPGdo has no argument though prepare statement has "$1".
(2)
I want to execute test_prep (2), but ECPGst_execute does not have argument.
Can SQL statement PREPARE be really used in ECPG?
[1] - https://www.postgresql.org/docs/11/ecpg-sql-prepare.html
Regards,
Ryohei Takahashi
В списке pgsql-hackers по дате отправления: