[gameprogrammer] Re: Slightly offtopic: SQL Command

Kevin Jenkins wrote:

> Ideas?

The obvious answer is that for the contrived example you provided, a
simple SELECT name FROM blah would return what you want.

For a more complicated situation, which I presume you actually need,
I'll reiterate my suggestion that you use the SERIAL keyword on the
primary key of the table on creation, and
  SELECT CURRVAL('tablename_columnname_seq')
at the end of the transaction, i.e.

BEGIN;
CREATE TABLE blah(name_id SERIAL PRIMARY KEY, name VARCHAR(64));
INSERT INTO blah(name) VALUES ('0');
COMMIT;
SELECT CURRVAL('blah_name_seq');
-- 
 Matthew Weigel
 hacker
 unique@xxxxxxxxxxx

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: