pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Antonello De Santis <ua01020@flashnet.it>
To: pgsql-interfaces@postgresql.org
Subject: Questions about pq library and ecpg
Date: Sat, 27 Mar 1999 15:43:23 +0100
Message-ID: <99032716072200.01169@zeman> (raw)

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




view thread (4+ messages)  latest in thread

Message-ID: <99032716072200.01169@zeman>
Permalink:  ../99032716072200.01169@zeman/
Also on:    postgresql.org/message-id/99032716072200.01169@zeman

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: ua01020@flashnet.it
  Subject: Re: Questions about pq library and ecpg
  In-Reply-To: <99032716072200.01169@zeman>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox