INSERT results - Mailing list pgsql-novice

From Mark Thomas
Subject INSERT results
Date
Msg-id 5.1.0.14.2.20020423165549.047372d0@pbegames.com
Whole thread Raw
Responses Re: INSERT results
List 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@pbegames.com ----> http://www.pbegames.com/~thomas
Play by Electron Games -> http://www.pbegames.com Free Trial Games


pgsql-novice by date:

Previous
From: "Joshua b. Jore"
Date:
Subject: Re: Storing .jpg files
Next
From: "Patrick Hatcher"
Date:
Subject: escape character in a function