Re: [COMMITTERS] pgsql-server: Clean up generation of default
От | Michael Glaesemann |
---|---|
Тема | Re: [COMMITTERS] pgsql-server: Clean up generation of default |
Дата | |
Msg-id | D1A9144A-BB6E-11D8-B1AB-000A95C88220@myrealbox.com обсуждение исходный текст |
Ответ на | Re: [COMMITTERS] pgsql-server: Clean up generation of default (Christopher Kings-Lynne <chriskl@familyhealth.com.au>) |
Ответы |
Re: [COMMITTERS] pgsql-server: Clean up generation of default
|
Список | pgsql-hackers |
On Jun 11, 2004, at 1:02 PM, Christopher Kings-Lynne wrote: >> 3. Or even create a pg_get_sequence() function: >> SELECT SETVAL(pg_get_sequence(schema.table, col), 17); > > Actually, this is the best solution :) John Hansen and I worked this up. It works, though it's not schema-aware, afaict. create or replace function last_val( text -- tablename , text -- colname ) returns bigint language 'sql'as ' select currval( (select split_part(adsrc,\'\'\'\',2) as seq from pg_class joinpg_attribute on (pg_class.oid = pg_attribute.attrelid) join pg_attrdef on (pg_attrdef.adnum = pg_attribute.attnum and pg_attrdef.adrelid = pg_attribute.attrelid) where pg_class.relname = $1 and pg_attribute.attname = $2) ); '; Might be a starting point. Michael Glaesemann grzm myrealbox com
В списке pgsql-hackers по дате отправления: