ECPG bug: PRAPARE FOR

Started by 1250kvover 5 years ago3 messagesbugs
Jump to latest
#11250kv
1250kv@gmail.com

Hello
I have code:

void main()
{
char *foo = "CALL "My_Proc"(?)";
EXEC SQL char *stmt = foo;
EXEC SQL PREPARE prep_stmt FROM :stmt;

EXEC SQL char *stmt2 = "CALL \x22OMy_Proc\x22(?)";
EXEC SQL PREPARE prep_stmt2 FROM :stmt2;

EXEC SQL PREPARE prep_stmt3 FROM "CALL "My_Proc"(?)";
}

ecpg --version
ecpg (PostgreSQL) 13.0 (Ubuntu 13.0-1.pgdg20.04+1)

ecpg sample.pgc -o sample.c
sample.pgc:10: ERROR: syntax error at or near "My_Proc"

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: 1250kv (#1)
Re: ECPG bug: PRAPARE FOR

On Tue, Oct 20, 2020 at 9:47 AM 1250kv <1250kv@gmail.com> wrote:

Hello
I have code:

void main()
{
char *foo = "CALL "My_Proc"(?)";
EXEC SQL char *stmt = foo;
EXEC SQL PREPARE prep_stmt FROM :stmt;

EXEC SQL char *stmt2 = "CALL \x22OMy_Proc\x22(?)";
EXEC SQL PREPARE prep_stmt2 FROM :stmt2;

EXEC SQL PREPARE prep_stmt3 FROM "CALL "My_Proc"(?)";
}

ecpg --version
ecpg (PostgreSQL) 13.0 (Ubuntu 13.0-1.pgdg20.04+1)

ecpg sample.pgc -o sample.c
sample.pgc:10: ERROR: syntax error at or near "My_Proc"

General usage questions regarding PostgreSQL and ECPG should be sent to the
-general list.

I don't know the correct answer here but maybe using dollar quoting within
the PostgreSQL SQL statement instead of double-quotes will help. Something
like:

prepare prep_stat3 from "call $$My_Proc$$()";

Asking an actual question does help others to figure out where you are
confused instead of just guessing.

David J.

#31250kv
1250kv@gmail.com
In reply to: David G. Johnston (#2)
Re: ECPG bug: PRAPARE FOR

I have also tried dollar quoting.
Unfortunately it fails at runtime:
*SQL error: syntax error at or near "$$My_Proc$$"*

On Tue, Oct 20, 2020 at 8:00 PM David G. Johnston <
david.g.johnston@gmail.com> wrote:

Show quoted text

On Tue, Oct 20, 2020 at 9:47 AM 1250kv <1250kv@gmail.com> wrote:

Hello
I have code:

void main()
{
char *foo = "CALL "My_Proc"(?)";
EXEC SQL char *stmt = foo;
EXEC SQL PREPARE prep_stmt FROM :stmt;

EXEC SQL char *stmt2 = "CALL \x22OMy_Proc\x22(?)";
EXEC SQL PREPARE prep_stmt2 FROM :stmt2;

EXEC SQL PREPARE prep_stmt3 FROM "CALL "My_Proc"(?)";
}

ecpg --version
ecpg (PostgreSQL) 13.0 (Ubuntu 13.0-1.pgdg20.04+1)

ecpg sample.pgc -o sample.c
sample.pgc:10: ERROR: syntax error at or near "My_Proc"

General usage questions regarding PostgreSQL and ECPG should be sent to
the -general list.

I don't know the correct answer here but maybe using dollar quoting within
the PostgreSQL SQL statement instead of double-quotes will help. Something
like:

prepare prep_stat3 from "call $$My_Proc$$()";

Asking an actual question does help others to figure out where you are
confused instead of just guessing.

David J.