Setting a default for nextval sequence

2017-11-27 Thread Robert Lakes
I'm attempting to set the default value for a serial column. I created a generic function that I am passing a table name as the only parameter. I had it working correctly, however, it does not seem to like the sequence name being the same name for each audit table that is created through the func

Setting a serial column with serial object that has a name that is built dynamically

2017-11-27 Thread Robert Lakes
How do I set a serial column with the next value when the serial object has a name that is built dynamically? EXECUTE 'CREATE SEQUENCE '|| *t_name *|| *'id_seq'* || ' OWNED BY '|| t_name || '_cdc'||'.table_id'; EXECUTE 'ALTER TABLE ' || quote_ident(t_name || '_cdc') || ' ALTER COLUMN table_id