Search Postgresql Archives

Re: Insert zero to auto increment serial column

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

 



loc wrote:
> I'm currently using an Informix Innovator-C database with Aubit4GL and I would like to migrate to
> PostgreSQL, it looks like the transition will not be too difficult, however there is one feature that
> I would like added to PostgreSQL.  Where is the best place to request a feature add?  With Informix
> inserting a 0 into a serial column will auto increment the serial value, MySQL also works this way.
> With PostgreSQL I will need to do a lot of code modification to my Aubit4GL programs, since I will
> need to either insert with the key word default or omit the serial column in the insert statement.  A
> typical insert with Aubit4GL looks like this:
> 
> create table table_name (link serial, col2 integer, col3 integer ....)
> define var_rec record like table_name.*
> let table_name.link = 0
> insert into table_name values(var_rec.*)
> 
> 
> As you can see, with Informix the serial column is set to 0 before the insert, with PostgreSQL I will
> need to list all the columns and will not be able to use the wildcard syntax, which supplies all the
> column names to the insert.  Setting the serial column to null to auto increment would also work for
> me.

If you don't want to modify your code, you could write a FOR EACH ROW BEFORE INSERT trigger
for the table that pulls the next value from the sequence if you insert 0.

I don't think that there is any chance that PostgreSQL's behaviour in this
case will be modified - first, the current behaviour is fine, and second,
such a change will break existing applications.

Yours,
Laurenz Albe

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux