How to call sequence in Oracle Forms
643155Jan 19 2009 — edited Jan 19 2009Hi,
I am using Oracle Developer Suite 10g. I want to call a sequence that I have created in SQL Plus. When I try to call the sequence in a trigger for a command button (WHEN-BUTTON-PRESSED) the compiler tells me that the sequence cannot be used in this context. I am passing the sequence to a procedure as a parameter. Let me show you some code:
My table is:
Location(loc_id, loc_name);
primary key is loc_id
My sequence is:
CREATE SEQUENCE loc_seq
MINVALUE 1
MAXVALUE 999999
START WITH 1
INCREMENT BY 1
CACHE 20;
My procedure is:
CREATE OR REPLACE PROCEDURE loc_change (v_loc_id IN Location.loc_id%TYPE, v_loc_name IN Location.loc_name%TYPE) AS
BEGIN
INSERT INTO Location(Location.loc_id, Location.loc_name)
VALUES (v_loc_id, v_loc_name);
COMMIT;
END loc_change;
My WHEN-BUTTON-PRESSED trigger is
BEGIN
loc_change(loc_seq.nextval, :DATA_BLOCK.VARIABLE);
END;
All that I need to do is generate a random number for the parameter passed that is the primary key for Location, from within my trigger. Any thoughts?