[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ITP: Slash, Sourceforge (fwd)



Craig Sanders wrote:
...
  >btw, i've looked (very briefly) at the Slash 0.90 code. it's a lot
  >better than the 0.3 version. it also uses DBD::mysql, so shouldn't be
  >too hard to port to DBD::Pg - my estimate is a couple of days to a week
  >of part-time hacking.
  >
  >i noticed that it uses a couple of auto-increment fields. these can be
  >implemented in postgres using a sequence and a trigger. e.g. to create
  >an auto-incrementing field called 'id' in table 'foo':
  >
 
... commands for autoincrementing ...

PostgreSQL can now do autoincrementing with a SERIAL data type, which is much
simpler:

junk=> create table c (id serial, name text);
NOTICE:  CREATE TABLE will create implicit sequence 'c_id_seq' for SERIAL column 'c.id'
NOTICE:  CREATE TABLE/UNIQUE will create implicit index 'c_id_key' for table 'c'
CREATE
junk=> insert into c (name) values ('Item 1');
INSERT 3003807 1
junk=> insert into c (name) values ('Item 2');
INSERT 3003808 1
junk=> select * from c;
id|name  
--+------
 1|Item 1
 2|Item 2
(2 rows)



-- 
Oliver Elphick                                Oliver.Elphick@lfix.co.uk
Isle of Wight                              http://www.lfix.co.uk/oliver
               PGP key from public servers; key ID 32B8FAA1
                 ========================================
     "Many are the afflictions of the righteous; but the 
      LORD delivereth him out of them all."             
                                        Psalm 34:19 



Reply to: