Re: PQoidValue - isn't it for...?
От | Jasen Betts |
---|---|
Тема | Re: PQoidValue - isn't it for...? |
Дата | |
Msg-id | h63e3r$1ko$2@reversiblemaps.ath.cx обсуждение исходный текст |
Ответ на | PQoidValue - isn't it for...? (Jim Michaels <jmichae3@yahoo.com>) |
Список | pgsql-general |
On 2009-08-12, Jim Michaels <jmichae3@yahoo.com> wrote: > --0-1559521671-1250064688=:25681 > Content-Type: text/plain; charset=us-ascii > > I am struggling to learn libpq. > > for some reason, I could not get an INSERT to produce an Oid. actually, what I am looking for, is to get the ID of thelast record inserted or to verify that I inserted a record successfully. I think you use PQresultStatus() for that.(?) > > Isn't PQoidValue() for getting the last INSERT id? or am I misunderstanding it? since 8.0 (iirc) you must specify "WITH OIDS" when you create the table or you won't get them, you can instead use "RETURNING someprimarykey" at the end of the insert query (for apropriate values of someprimarykey) and get a different sort of handle on the new row > Oid oid = PQoidValue(pgr); > if (0 == oid) { > printf("ERROR: INSERT operation failed!\n"); You should be printing the result from PQlastError() here too.
В списке pgsql-general по дате отправления: