pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
libpq interfacing
2+ messages / 2 participants
[nested] [flat]

* libpq interfacing
@ 2002-03-05 04:13 arun kv <arun@library.iisc.ernet.in>
  2002-03-05 14:58 ` Re: libpq interfacing Miguel Carvalho <miguel@ipatimup.pt>
  0 siblings, 1 reply; 2+ messages in thread

From: arun kv @ 2002-03-05 04:13 UTC (permalink / raw)
  To: pgsql-php; +Cc: dornelas@mssystems.com; gerzson@php.net; zsheran@yahoo.com; dbrown@centennialwines.com

hello,
      i am accessing a postgresql table using libpq interface ( i.e. c
program) i am opening a text file and reading contents and trying to
insert the same to postgresql table. suppose i read some string
like"computer" from file and stored in a variable key. no i want to write
the content of key to table i.e using insert command. if i give insert
into table tbname (aaa,bbb) values ('aaa','key'); it inserts aaa and key
to table which was to be aaa and computer. this is a c program using libpq
tool. can someone help me in executing this.
   thanx 
   Arun




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

* Re: libpq interfacing
  2002-03-05 04:13 libpq interfacing arun kv <arun@library.iisc.ernet.in>
@ 2002-03-05 14:58 ` Miguel Carvalho <miguel@ipatimup.pt>
  0 siblings, 0 replies; 2+ messages in thread

From: Miguel Carvalho @ 2002-03-05 14:58 UTC (permalink / raw)
  To: pgsql-php

> hello,
>      i am accessing a postgresql table using libpq interface ( i.e. c
> program) i am opening a text file and reading contents and trying to
> insert the same to postgresql table. suppose i read some string
> like"computer" from file and stored in a variable key. no i want to
> write the content of key to table i.e using insert command.


Use something like is:
char buffer[1024];
//char_pointer_for_field1 AND  char_pointer_for_field2 are char*
//type variables

 buffer = sprintf("INSERT INTO TABLE(field1,field2) VALUES('%s','%s'),
                char_pointer_for_field1, char_pointer_for_field2
          );

NOTE: You may have to use a bigger buffer string. This depends on the
length of variables char_pointer_for_field1 and char_pointer_for_field2.
If for some reason the buffer space reserved is smaller, it means that the
previous sprinf instaruction will *corrupt* other SO memory...and you will
notice an error like: Segmentation fault.






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


end of thread, other threads:[~2002-03-05 14:58 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-03-05 04:13 libpq interfacing arun kv <arun@library.iisc.ernet.in>
2002-03-05 14:58 ` Miguel Carvalho <miguel@ipatimup.pt>

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