On Sun, 7 Feb 1999, hoelc wrote:
> (2) How to put variables into the SQL?
> I use C program to access PostgreSQL with libpq, and use PQexec(
> ) to send the query. One of the failed example of mine,
I'd recommend using ecpg that comes with postgresql in the place of libpq
direct. It is IMHO orders of magnitude easier than libpg alone. The
syntax follows the same as Oracle's Pro*C so you can pretty much use any
of their manuals and get a working program. I found an on-line copy of
the Pro*c manual at
With it you end up with something like the following in your code
insert into customer(id,name_first,name_middle,name_last,company,
values (:id,:name_first, :name_middle, :name_last,
the names preceeded by : are c variables. The ecpg preprocessor replaces
this easily readable code with much nastier looking c code that does what
The author of the code is very responsive to few problem reports I have
sent him and has sent patches, or workarounds to me usually within 24
In the few cases you can't figure out a way to make something happen using
ecpg I believe you can mix the libpg and ecpg code in the same program.
The only place I could see a need for this is when you'd need the
functionality given by Pro*C's Dynamic SQL which ecpg doesn't yet support,
but I think its in the works.
You can find examples of ecpg code in the source tree
> (3) How to check who are the users in PostgreSQL system?
select * from pg_user;
James Thompson 138 Cardwell Hall Manhattan, Ks 66506 785-532-0561
Kansas State University Department of Mathematics
In response to
pgsql-interfaces by date
|Next:||From: Dinesh Patil||Date: 1999-02-07 01:42:29|
|Subject: help on libpq|
|Previous:||From: hoelc||Date: 1999-02-07 00:45:22|
|Subject: question on accessing PostgreSQL with C|