I am trying to populate a column's value based on sequence.
I create the sequence:
CREATE SEQUENCE sch1.incrementbyone_seq; ALTER SEQUENCE sch1.incrementbyone_seq
OWNED BY sch1.featurepoint1.seqnumber_;
This does not work, the "seqnumber_" coloumn never gets populated. I have made sure that the owner and the schema name of the sequence are the same and located on the same schema as the Featurepoint1 Feature Class
The sequence itself is correct when its is called by a query "SELECT nextval('sch1.incrementbyone_seq');" it gives out the correct number.
How do I enable the sequence to be called when editing happens ?
Then I try using a trigger and function:
Function: new.seqnumber:= nextval('sch1.incrementbyone_seq');
Trigger: before INSERT OR UPDATE ON sch1.featurepoint1 FOR EACH ROW EXECUTE PROCEDURE function_name();
It works perfectly.
Whats the difference between using and not using trigger ? Why the trigger works ?