From: | Antonello De Santis <ua01020(at)flashnet(dot)it> |
---|---|
To: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Questions about pq library and ecpg |
Date: | 1999-03-27 14:43:23 |
Message-ID: | 99032716072200.01169@zeman |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Hi,
I'm a new subscriber of this mailing list and new user of postgresql, let me
first greet everybody reading this mail.
I have a couple of questions about libpq and ecpg.
Is it possible to accomplish a query on a table whose name is specified in a
variable? That is, something like the following:
strcpy(str, 'table');
result=PQexec(conn, "insert into str values('Rome', 10)");
I guess a code like the above one would not give the expected result..... Is
there a way to work that out?
I'm trying to use the ecpg preprocessor to pass arguments of a query in
variables, but I get a few errors.... Here's the piece of code that doesn't
work:
exec sql begin declare section;
char str[80];
exec sql end declare section;
strcpy(str, "squadre");
exec sql connect 'prova';
exec sql select * from :str;
exec sql commit;
exec sql insert into :str values('Samp', 10);
exec sql commit;
exec sql disconnect 'prova';
ecpg gives an error message saying: parse error in line 10, that is line "exec
sql insert into :str values('Samp', 10);". If I replace var str with the name
of the table, it works correctly instead. The syntax seems to be correct so I
have no idea about where the error is.
The last question for now is the following: how can I display the content of a
table using ecpg instructions? The statement "exec sql select * from :str;",
doesn't print anything on screen..... Any trick please? Probably this is a
stupid question, so forgive me, I'm new to postgresql! :-)
Thanks to everybody.
Greetings,
Antonello De Santis
From | Date | Subject | |
---|---|---|---|
Next Message | Wojciech Kromer | 1999-03-27 17:45:19 | PsqlODBC and 'lo' type in PostrgreSQL 6.4.x |
Previous Message | Byron Nikolaidis | 1999-03-27 06:14:47 | Re: [Fwd: [INTERFACES] type error inserting large obj, Win32 ODBC] |