pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
(no subject)
4+ messages / 3 participants
[nested] [flat]

* (no subject)
@ 2004-01-29 13:08 MUKTA <muktavasudeva@hfcl.com>
  2004-01-29 13:11 ` Re: Viorel Dragomir <bc@vio.ro>
  2004-01-30 03:03 ` Re: Chris Travers <chris@travelamericas.com>
  0 siblings, 2 replies; 4+ messages in thread

From: MUKTA @ 2004-01-29 13:08 UTC (permalink / raw)
  To: pgsql-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

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re:
  2004-01-29 13:08 (no subject) MUKTA <muktavasudeva@hfcl.com>
@ 2004-01-29 13:11 ` Viorel Dragomir <bc@vio.ro>
  2004-01-29 14:15   ` Re: MUKTA <muktavasudeva@hfcl.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Viorel Dragomir @ 2004-01-29 13:11 UTC (permalink / raw)
  To: MUKTA <muktavasudeva@hfcl.com>; pgsql-sql

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

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re:
  2004-01-29 13:08 (no subject) MUKTA <muktavasudeva@hfcl.com>
  2004-01-29 13:11 ` Re: Viorel Dragomir <bc@vio.ro>
@ 2004-01-29 14:15   ` MUKTA <muktavasudeva@hfcl.com>
  0 siblings, 0 replies; 4+ messages in thread

From: MUKTA @ 2004-01-29 14:15 UTC (permalink / raw)
  To: Viorel Dragomir <bc@vio.ro>; pgsql-sql

Hi!!
 wow, ur help was extremely helpfull! thanx a bunch! i just joined this pgsql project 2 days ago so i dunno bout php etc, i guess i wont need to use the ecpg stuff for now..
Thanx a lot!
Bye
PS: how did u know i was an artist! :)
  ----- Original Message ----- 
  From: Viorel Dragomir 
  To: MUKTA ; pgsql-sql@postgresql.org 
  Sent: Thursday, January 29, 2004 6:41 PM
  Subject: Re: [SQL] 


  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

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re:
  2004-01-29 13:08 (no subject) MUKTA <muktavasudeva@hfcl.com>
@ 2004-01-30 03:03 ` Chris Travers <chris@travelamericas.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Chris Travers @ 2004-01-30 03:03 UTC (permalink / raw)
  To: MUKTA <muktavasudeva@hfcl.com>; pgsql-sql

You can also use PGexecParams() (see the libpq documentation).  It can be a little more cumbersome to use, though.

Best Wishes,
Chris Travers
  ----- Original Message ----- 
  From: MUKTA 
  To: pgsql-sql@postgresql.org 
  Sent: Thursday, January 29, 2004 8:08 PM
  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

^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2004-01-30 03:03 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-01-29 13:08  MUKTA <muktavasudeva@hfcl.com>
2004-01-29 13:11 ` Re: Viorel Dragomir <bc@vio.ro>
2004-01-29 14:15   ` Re: MUKTA <muktavasudeva@hfcl.com>
2004-01-30 03:03 ` Re: Chris Travers <chris@travelamericas.com>

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