Re: libpq/INSERT

Поиск
Список
Период
Сортировка
От Brett W. McCoy
Тема Re: libpq/INSERT
Дата
Msg-id Pine.LNX.4.30.0104241218010.20756-100000@chapelperilous.net
обсуждение исходный текст
Ответ на libpq/INSERT  ("Andy Champion" <andychampion@hotmail.com>)
Список 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 по дате отправления:

Предыдущее
От: "Oliver Elphick"
Дата:
Сообщение: Re: libpq/INSERT
Следующее
От: wsmuir@islandnet.com
Дата:
Сообщение: SPI