Re: nextval syntax
От | Tom Lane |
---|---|
Тема | Re: nextval syntax |
Дата | |
Msg-id | 24424.1048881311@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | nextval syntax (Justin Georgeson <jgeorgeson@unboundtech.com>) |
Список | pgsql-ports |
Justin Georgeson <jgeorgeson@unboundtech.com> writes: > Is there a way to have an application use "select sequence_name.nextval > ..." in postgres? I want to keep the application working on oracle, but > want to use postgres for development/staging. How bad do you want it? If you can tolerate making an interface function for each sequence, you could do this: regression=# create sequence seq; CREATE SEQUENCE regression=# select seq.nextval; ERROR: No such attribute seq.nextval regression=# create function nextval(seq) returns int8 as regression-# 'select nextval(''seq'')' language sql; CREATE FUNCTION regression=# select seq.nextval; nextval --------- 1 (1 row) regression=# select seq.nextval; nextval --------- 2 (1 row) (This works in 7.3, not sure about older releases.) Beware though of using this in more complex selects, as the parser is likely to think you mean a join of the sequence to the other tables... regards, tom lane
В списке pgsql-ports по дате отправления: