pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: email@juergen-cappel.de
To: Viorel Dragomir <bc@vio.ro>
Cc: pgsql-sql@postgresql.org
Subject: Re:
Date: Thu, 29 Jan 2004 14:36:01 +0100
Message-ID: <6312635$107538310640190b424983f6.38446324@config19.schlund.de> (raw)


You might also consider using ecpg which allows a syntax like:

int a, b, c;
EXEC SQL INSERT INTO mytable ( :a, :b, :c );

See http://www.postgresql.org/docs/current/interactive/ecpg.html for
details.

HTH

Jürgen


Viorel Dragomir <bc@vio.ro> schrieb am 29.01.2004, 14:11:44:
> So, you are an artist. Isn't it? :)
> Your query is actually a string.
> This is your string: INSERT into table values(a,b,c,d)
> 
> You must change your string to actually use values of tha a, b...
> You can make this string with sprintf
> sprintf(string, "INSERT into table values(%d,%d,%d,%d)", a, b, c, d);
> 
> Then you launch:
> res=PQexecute(Conn, string);
> 
> Why don't you use PHP? Is easier.
> 
> Have a nice day
>   ----- Original Message ----- 
>   From: MUKTA 
>   To: pgsql-sql@postgresql.org 
>   Sent: Thursday, January 29, 2004 15:08
>   Subject: [SQL] 
> 
> 
>   Hi I have an urgent problem
>   I want to insert values into a table using the C syscalls provided by the libpq library, but i find that i can not insert into the table when i use variables instead of values...like so:
>   int a,b,c,d;
>   using the C function 
> 
>   res=PQexecute(Conn,"INSERT into table values(a,b,c,d));....
> 
>   executing above statement with plain integers does fine and inserts them into table..
> 
>   Is there some special way to insert variables rather than plain values? do i have to build functions (in sql) or somehting?help!
>   Thanx



Message-ID: <6312635$107538310640190b424983f6.38446324@config19.schlund.de>
Permalink:  ../6312635$107538310640190b424983f6.38446324@config19.schlund.de/
Also on:    postgresql.org/message-id/6312635$107538310640190b424983f6.38446324@config19.schlund.de

 · 

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-sql@postgresql.org
  Cc: email@juergen-cappel.de, bc@vio.ro
  Subject: Re:
  In-Reply-To: <6312635$107538310640190b424983f6.38446324@config19.schlund.de>

* 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