From: | "Miguel Carvalho" <miguel(at)ipatimup(dot)pt> |
---|---|
To: | <pgsql-php(at)postgresql(dot)org> |
Subject: | Re: libpq interfacing |
Date: | 2002-03-05 14:58:42 |
Message-ID: | 11436.195.23.103.182.1015340322.squirrel@www.ipatimup.pt |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | mark boylan | 2002-03-06 02:33:54 | SLL with PHP? |
Previous Message | arun kv | 2002-03-05 04:13:59 | libpq interfacing |