[gameprogrammer] Re: Slightly offtopic: SQL Command
- From: Matthew Weigel <unique@xxxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Fri, 10 Nov 2006 18:42:07 -0600
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
- References:
- [gameprogrammer] Re: Slightly offtopic: SQL Command
- From: Kevin Jenkins
Other related posts:
- » [gameprogrammer] Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- » [gameprogrammer] Re: Slightly offtopic: SQL Command
- [gameprogrammer] Re: Slightly offtopic: SQL Command
- From: Kevin Jenkins