libpq - getting value of SERIAL field when INSERT-ing?

Поиск
Список
Период
Сортировка
От Roy's Email
Тема libpq - getting value of SERIAL field when INSERT-ing?
Дата
Msg-id BAY161-W47D80B4AF95A1A565E6B396160@phx.gbl
обсуждение исходный текст
Ответы Re: libpq - getting value of SERIAL field when INSERT-ing?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-novice
Using libpq, how do I get the return value from an INSERT statement?
 
CREATE TABLE foo ( pk SERIAL , val text, PRIMARY KEY (pk) );
INSERT INTO foo VALUES ( DEFAULT, 'stuff' ) RETURNING (pk);
 
How do I get the value assigned to 'pk'?  I assume it's in the 'PGresult' returned from 'PQexec()', but I can't find anything in the documentation for 'PGresult' that appears to discuss this particular use.

Regards,

- Roy

=*=*=
Always do right.
This will gratify some people and astonish the rest. - Mark Twain

The truth is rarely pure, and never simple. - Oscar Wilde
 

В списке pgsql-novice по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: Trouble including "pg_type.h"
Следующее
От: Tom Lane
Дата:
Сообщение: Re: libpq - getting value of SERIAL field when INSERT-ing?