Re: libpq/INSERT - Mailing list pgsql-interfaces

From Brett W. McCoy
Subject Re: libpq/INSERT
Date
Msg-id Pine.LNX.4.30.0104241218010.20756-100000@chapelperilous.net
Whole thread Raw
In response to libpq/INSERT  ("Andy Champion" <andychampion@hotmail.com>)
List pgsql-interfaces
On Tue, 24 Apr 2001, Andy Champion wrote:

> Hi, i'm trying to insert data pulled into a postgresql database but i'm
> having some problems with the inserts.
>
> i know that this:
> sprintf(insert_string, "INSERT INTO udpdata VALUES (1234);\n");
>
> is a valid statment, but how do i alter this so that instead of the 1234
> i insert the value of a variable?

int value = 1234;
sprintf(insert_string, "INSERT INTO udpdata VALUES(%d);\n", value);

Check the man page or the documentation for your C run-time libraries for
the sprintf-like functions (printf, sprintf, fprintf, etc) for information
on formatting rules.

-- Brett                                   http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
They are relatively good but absolutely terrible.    -- Alan Kay, commenting on Apollos



pgsql-interfaces by date:

Previous
From: "Oliver Elphick"
Date:
Subject: Re: libpq/INSERT
Next
From: wsmuir@islandnet.com
Date:
Subject: SPI