I have table containing different types of documents (type A, B and C). Each document type must have separate sequential ID starting at 1
ID of first inserted record of type A must be set to 1 ID of first inserted record of type B must be also set to 1 ID of second record of type A must be set to 2 etc. I tried to implement this as CREATE SEQUENCE a_id_seq; CREATE SEQUENCE b_id_seq; CREATE SEQUENCE c_id_seq; CREATE TABLE documents ( doctype CHAR(1), id NUMERIC DEFAULT nextval(doctype ||'_dokumnr_seq'), documentcontents TEXT ); but got an error ERROR: cannot use column references in default expression Any idea how to implement this ? Andrus. ---------------------------(end of broadcast)--------------------------- TIP 8: explain analyze is your friend