INSERT results

From: Mark Thomas <thomas(at)pbegames(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: INSERT results
Date: 2002-04-23 21:24:43
Message-ID: 5.1.0.14.2.20020423165549.047372d0@pbegames.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Suppose I have a sequence/table:

CREATE SEQUENCE "id_seq" start 5000 increment 1;

CREATE TABLE "users"
(
"id" integer primary key default nextval('id_seq') NOT NULL,
"name" varchar(64)
);

I'm using libpq. If I do something like this:

PGconn *conn; // assume initialized
const char *q = "INSERT INTO users (name) VALUES ('J Doe')";
PGresult *res = PQexec(conn, q);

At this point is there any way for my app to determine the id value of the
newly inserted record?

Mark Thomas
---
thomas(at)pbegames(dot)com ----> http://www.pbegames.com/~thomas
Play by Electron Games -> http://www.pbegames.com Free Trial Games

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Joshua b. Jore 2002-04-23 21:24:50 Re: Storing .jpg files
Previous Message Richard A Lough 2002-04-23 19:27:44 Losing synchronisation with server