I’m trying to insert a data into oracle database(version 11g xe).But when i’m trying to execute the procedure using toad i’m getting the error as ‘ORA-01403: no data found’.
Here’s my code
CREATE OR REPLACE PROCEDURE ACTSINFO.sp_Insert_WorkDetails
(p_workname IN varchar ,
p_workaddress IN varchar)
IS
BEGIN
insert into workdetails (workname,workaddress) values (p_workname,p_workaddress);
END sp_Insert_WorkDetails;
I tried to execute the procedure using the below statememt
EXEC sp_Insert_WorkDetails('test','test');
Also i’ve defined a trigger and sequence for the autoincrement of workdetailsid in table workdetails
Sequence is as follows
ALTER SEQUENCE ACTSINFO.WORKDETAILS_WORKID_SEQ
INCREMENT BY 1
MINVALUE 0
MAXVALUE 9999999999999999999999999999
NOCACHE
NOCYCLE
NOORDER
Trigger is as follows
DROP TRIGGER ACTSINFO.WORKDETAILS_INSERT;
CREATE OR REPLACE TRIGGER ACTSINFO.WORKDETAILS_INSERT
BEFORE INSERT
ON ACTSINFO.WORKDETAILS
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
BEGIN
SELECT WORKDETAILS_WORKID_SEQ.NEXTVAL INTO :NEW.WORKID FROM WORKDETAILS;
END;
I’m new to oracle.Pls help me…
Your trigger is the problem:
If there are no rows in workdetails the select will return nothing. Even worse, if your workdetails table has more than one row this will also fail miserably.
You really want the following:
or – if you are on 11g – then you can use: