Hello guys,
I would like to ask, how to do an autoincrement in C9, using PGSQL.
I want to do it using two columns.
EXAMPLE:
A B
1 1
1 2
2 1
1 3
2 2
ANY TIPS or CODE?
Hello guys,
I would like to ask, how to do an autoincrement in C9, using PGSQL.
I want to do it using two columns.
EXAMPLE:
A B
1 1
1 2
2 1
1 3
2 2
ANY TIPS or CODE?
Should be coded in a before insert trigger.for the PG table.
An example for the before insert PG trigger code:
IF NEW.b = 0 OR NEW.b IS NULL THEN
SELECT COALESCE(max(b),0)+1 INTO NEW.b FROM mytable WHERE a = NEW.a;
END IF;
RETURN NEW;