Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

No Data Found Error in Trigger (After or Before)

User413172May 10 2013 — edited May 10 2013
Dear All,

We have the following trigger in database, whenever we try to insert the record in WIP_OPERATIONS , NO DATA FOUND exception has been thrown, when we debugged, we did not find any issue. The first select statement is getting failed even though there is the value coming for :NEW.wip_entity_id and when we execute the query separately in database with the :NEW.WIP_ENTITY_ID, its getting the value. What could be the reason? Can't we use SELECT Statement in AFTER or BEFORE INSERT trigger? Any Idea why its throwing NO_DATA_FOUND Exception?

CREATE OR REPLACE TRIGGER sdm_brasil_wj_ops_iface_trg
BEFORE INSERT OR DELETE
ON WIP_OPERATIONS
REFERENCING
NEW AS NEW
OLD AS OLD
FOR EACH ROW
DECLARE
ln_status NUMBER(10) := 0;
ln_item_id Number(20);
--
lc_txn_type VARCHAR2(1);
v_interface_flag VARCHAR2(1);
v_err_msg VARCHAR2(2000) := NULL;
v_error VARCHAR2(2000) := NULL;
--
lb_insert_iface BOOLEAN := FALSE;
--
lr_discrete_job_ops wip_operations%ROWTYPE := NULL;
--
BEGIN

lr_discrete_job_ops.wip_entity_id := :NEW.wip_entity_id;

BEGIN

INSERT INTO APPS.XX_TEMP VALUES (':NEW.wip_entity_id ' || :NEW.wip_entity_id);

SELECT status_type
INTO ln_status
FROM wip_discrete_jobs
WHERE wip_entity_id = :NEW.wip_entity_id;


INSERT INTO APPS.XX_TEMP VALUES ('ln_status' || ln_status);

EXCEPTION
WHEN NO_DATA_FOUND THEN
ln_status := 0;
v_error := 'ERR001: NO DATA FOUND - Primary Item Id for WJ ID : '||TO_CHAR(lr_discrete_job_ops.wip_entity_id)||' => '||SUBSTR(SQLERRM,1,500);
dbg_pk.appmsg (1, vn||v_error);
WHEN TOO_MANY_ROWS THEN
ln_status := 1;
v_error := 'ERR001: TOO Manu Rows - Primary Item Id for WJ ID : '||TO_CHAR(lr_discrete_job_ops.wip_entity_id)||' => '||SUBSTR(SQLERRM,1,500);
dbg_pk.appmsg (1, vn||v_error);
WHEN OTHERS THEN
ln_status := 2;
v_error := 'ERR001: Others - Primary Item Id for WJ ID : '||TO_CHAR(lr_discrete_job_ops.wip_entity_id)||' => '||SUBSTR(SQLERRM,1,500);
dbg_pk.appmsg (1, vn||v_error);
END;
This post has been answered by BluShadow on May 10 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 7 2013
Added on May 10 2013
9 comments
2,898 views