Received: from mail.ipatimup.pt (peterpan.ipatimup.pt [194.65.114.74]) by postgresql.org (Postfix) with ESMTP id 1BBBB475BBD for ; Tue, 5 Mar 2002 10:06:00 -0500 (EST) Received: from ipatimup.pt (localhost [127.0.0.1]) by mail.ipatimup.pt (8.11.6/8.11.6-IPATIMUP) with SMTP id g25EwgI25327 for ; Tue, 5 Mar 2002 14:58:42 GMT Received: from 195.23.103.182 (proxying for unknown) (SquirrelMail authenticated user miguel) by www.ipatimup.pt with HTTP; Tue, 5 Mar 2002 14:58:42 -0000 (WET) Message-ID: <11436.195.23.103.182.1015340322.squirrel@www.ipatimup.pt> Date: Tue, 5 Mar 2002 14:58:42 -0000 (WET) Subject: Re: libpq interfacing From: "Miguel Carvalho" To: In-Reply-To: References: X-Priority: 3 Importance: Normal X-MSMail-Priority: Normal Reply-To: miguel@ipatimup.pt X-Mailer: SquirrelMail (version 1.2.2) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Archive-Number: 200203/5 X-Sequence-Number: 974 > 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.