Passsing value to Before Delete Trigger
I've never seen this done and wanted to see if it's even possible.
They have created an application using access to fill out a form that a user is signed into. Once the form is created they submit the data to Oracle calling a process as a generic user. They want to be able to capture the user that was logged into Access to update when the trigger is fired and audit record created.
I'm fairly new to what they are doing here and I think the easiest is just to create a procedure to update the audit table and delete the record, and forget about trying to use a trigger for this purpose.
Any thoughts out there that might have more experience in this area.
Thanks
...and when that package state is discarded by a patch release the sumbit button on the access form will stop working randomly, and the users will be figure out that they need to click the button twice sometimes and just to be safe always, and you'll end up with loads of duplicated audit entries.
...and when someone deletes by logging in as the "generic user" direct from an Access query, or ODBC or SQL*Plus or some random other tool, you'll have no idea who did it.
The generic user idea is a bad one.
Similar Messages
-
Before delete trigger and foreign key relationship
Hi,
I am analysing one database for migration. On one parent table there is before delete trigger , to delete records from child. Also there is foreign key relationship on child table for this parent table.
When I am deleting a row from parent, message gets displayed as "there are child records found."
I would like to know, if there is foreign key relatioship then delete trigger on parent does't work, what is exactly happening?Could you post that trigger code and the Oracle version as well?
With basic assumptions, I can't reproduce what you have stated here.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table parent (id number primary key);
Table created.
SQL> create table child (id number);
Table created.
SQL> alter table child add constraint fk_parent foreign key (id) references parent;
Table altered.
SQL> create or replace trigger bdr_parent
2 before delete on parent
3 for each row
4 begin
5 delete from child where id = :old.id;
6 end;
7 /
Trigger created.
SQL> insert into parent (id) values (1);
1 row created.
SQL> insert into child (id) values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> delete from parent where id = 1;
1 row deleted.
SQL> select * from parent;
no rows selected
SQL> select * from child;
no rows selected
SQL> rollback;
Rollback complete.
SQL> alter table child drop constraint fk_parent;
Table altered.
SQL> alter table child add constraint fk_parent foreign key (id) references parent on delete cascade;
Table altered.
SQL> delete from parent where id = 1;
delete from parent where id = 1
ERROR at line 1:
ORA-04091: table SCOTT.CHILD is mutating, trigger/function may not see it
ORA-06512: at "SCOTT.BDR_PARENT", line 2
ORA-04088: error during execution of trigger 'SCOTT.BDR_PARENT'
SQL> -
Get Current SQL in Before delete trigger
Hi,
I have created a before delete trigger to track which records are deleted from a table I need to know what statements fires the trigger. can someone please describe how I can retrieve the current SQL.
using sys_context('userenv','CURRENT_SQL') returns null for CURRENT SQL
Note:
For me the easier is to enable auditing and audit delete on the table however at the moment I cant get a downtime from the business to bounce the database to enable auditing.
CREATE OR REPLACE TRIGGER before_delete BEFORE DELETE
ON AUDIT_TEST_TAB
FOR EACH ROW
DECLARE
v_username varchar2(50);
v_stmt varchar2(255);
v_client_info varchar2(200);
v_os_user varchar2(50);
v_machine varchar2(50);
v_program varchar2(50);
v_module varchar2(50);
v_auth_type varchar2(200);
v_ip_addr varchar2(200);
v_sql_statement VARCHAR2(4000);
BEGIN
SELECT sys_context ('USERENV', 'CURRENT_SQL')
INTO v_sql_statement
FROM dual;
-----------insert into logging table statment ----
end;A few comments.
Lets assume you run a delete statement that deletes 550 rows from your table. If your trigger is working then the very same statement would be stored 550 times. I think an BEFORE or better an AFTER delete STATEMENT level trigger would be the better choice. Why AFTER? Because if the delete operation fails, for example because of existing child records, then everything is rolled back anyway to the implicit savepoint just before the delete.
So to store the SQL statement the correct trigger would be an AFTER STATEMENT DELETE trigger.
Now what to store: You want the sql statement. You could try to find the cursor/currently running SQL. It might be tricky to separate that from the SQLs that you run to find this out.
It could even be possible to simply save all commands that are in your PGA/Cached cursor area. First find out yur session, then store the SQL_text (first 60 chars) for all the cursors in this session by using v$open_cursor or the first 1000 chars by using v$sql.
Here are a few views that might be helpful. v$session , v$open_cursor, v$sql, v$sqltext, v$sql_bind_data, v$sql_bind_capture, dba_hist_sqltext -
How to make before delete trigger
Hi all
I want make before delete trigger
I have 2 tables hr_api_transactions and new_table
when I delete records from hr_api_transations table
then that deleted record should be stored/insert in new_table table
for that purpose I need before delete trigger
How can I make It?Hi
I have written following code but it gives an error
CREATE OR REPLACE TRIGGER before_delete_trigger
BEFORE DELETE
ON HR_API_TRANSACTIONS
FOR EACH ROW
DECLARE
BEGIN
delete from new_table where new_table.name = OLD.hr_api_transactions.api_addtnl_info;
END;
TRIGGER BEFORE_DELETE_TRIGGER compiled
Errors: check compiler logafter show errors it shows
4/54 PL/SQL: ORA-00904: "OLD"."HR_API_TRANSACTIONS"."API_ADDTNL_INFO": invalid identifier
4/9 PL/SQL: SQL Statement ignoredhere hr_api_transaction is table which contain API_ADDTNL_INFO column
and name column of new_table and API_ADDTNL_INFO column of
HR_API_TRANSACTIONS table are same -
We are trying to determine who (like in what applicaton) is deleting rows in one table that leaves "orphaned" rows in another.
We create the following trigger...
create or replace Trigger EFA_TRG_AUDIT
before delete on EFA_EXTERNAL_FILE_ATTACHMENT
for each row
declare
OS_USER varchar2 (20);
HOST varchar2 (20);
MODULE varchar2 (48);
SESSION_USER varchar2 (20);
Begin
if :old.EFA_LDS_UID is not null then
SELECT substr(SYS_CONTEXT ('USERENV', 'SESSION_USER'),1,20) into SESSION_USER from dual;
SELECT module into MODULE from v$session where audsid=userenv('SESSIONID');
SELECT substr(SYS_CONTEXT ('USERENV', 'HOST'),1,20) into HOST from dual;
SELECT substr(SYS_CONTEXT ('USERENV', 'OS_USER'),1,20) into OS_USER from dual;
insert into EFAA_EFA_AUDIT values(
:old.EFA_UID,
:old.EFA_SYT_CODE_PARENT,
:old.EFA_PARENT_KEY,
:old.EFA_SEQUENCE,
:old.EFA_FILENAME,
:old.EFA_DESC,
:old.EFA_LDS_UID,
:old.EFA_CREATE_DATE,
:old.EFA_USR_UID_CREATED_BY,
:old.EFA_LAST_UPDATE_DATE,
:old.EFA_USR_UID_UPDATED_BY,
:old.EFA_FAT_CODE,
:old.EFA_FILE_SIZE,
'DELETE',
HOST,
OS_USER,
MODULE,
User,
Sysdate);
end if;
end;
This will create an "audit table" which works fine but includes ALL deletes including valid deletes that leave no "orphans" (EFA_LDS_UID).
The LDS table can have rows that are not related to the EFA so a constraint cannot be used.
Any ideas?no need to clean up the data. just create the FK as NOVALIDATE
from the SQL Reference manual:
ENABLE NOVALIDATE ensures that all new DML operations on the constrained data comply with the constraint. This clause does not ensure that existing data in the table complies with the constraint and therefore does not require a table lock -
Help with a Before Delete Triggger
Hello:
When I do a delete operation on a table that has the following trigger, it comes up with an error message,
":ORA-04091: table INNOBOX.SUGGEST is mutating, trigger/function may not see it
ORA-06512: at "INNOBOX.DELSUGGEST", line 44
ORA-04088: error during execution of trigger 'INNOBOX.DELSUGGEST'"
Can somebody tell me what I am doing wrong?
CREATE OR REPLACE TRIGGER INNOBOX.delSuggest
BEFORE DELETE
ON INNOBOX.SUGGEST
FOR EACH ROW
BEGIN
INSERT INTO INNOBOX.SUGGEST_LOG
Sugg_Log_ID_N,
Sugg_No_N,
Cat_CD_C,
Liaison_CD_C,
S_Desc_C,
L_Desc_C,
S_Stat_CD_C,
S_Stat_DT,
Benefit_C,
Cost_Sav_C,
Resol_C,
D_Stat_CD_C,
D_Stat_DT,
ACD_CD_C,
Cr_By_ID_C,
Cr_DT,
Up_By_ID_C,
Up_DT
VALUES
INNOBOX.Suggest_Log_Seq.NEXTVAL,
:old.Sugg_No_N,
:old.Cat_CD_C,
:old.Liaison_CD_C,
:old.S_Desc_C,
:old.L_Desc_C,
:old.S_Stat_CD_C,
:old.S_Stat_DT,
:old.Benefit_C,
:old.Cost_Sav_C,
:old.Resol_C,
:old.D_Stat_CD_C,
:old.D_Stat_DT,
'D',
:old.Cr_By_ID_C,
:old.Cr_DT,
:old.Up_By_ID_C,
:old.Up_DT
DELETE SUGGEST WHERE Sugg_No_N = :old.Sugg_No_N
END;
Thanks.
VenkiHi,
Try to remove the last line from your trigger :
DELETE SUGGEST WHERE Sugg_No_N = :old.Sugg_No_N, you delete a line from a table for which there is the same before delete trigger, also there is a muttating trigger.
HTH,
Nicolas. -
Hi all,
I have a situation like this
I have a table like
SQL> desc system_user
Name Null? Type
ID NOT NULL NUMBER(12)
USER_ID NOT NULL VARCHAR2(30)
SQL> SELECT * FROM SYSTEM_USER
2 ORDER BY CTUT_ID;
CTUT_ID CURRENT_USER_ID
1 KTYLOR
2 EXAMPLE
3 SCOTT
SQL> DESC ALL_USERS;
Name Null? Type
USERNAME NOT NULL VARCHAR2(30)
USER_ID NOT NULL NUMBER
CREATED NOT NULL DATE
What i need to do is i need to have before delete trigger to check the following condition when user try to delete a record in table
SYSTEM_USER
1) suppose user is trying to delete a record "SCOTT" IN TABLE
SYSTEM_USER
CONDITION SHOULD CHECK THAT IF USER_NAME EXITS IN TABLE "ALL_USER"
1)IF HE EXITS THEN RAISE ERROR
2)IF HE IS NOT EXITS THEN DELETE THE RECORD IN TABLE "SYSTEM_USER"
SO I WROTE A CODE FOR TRIGGER
SQL> CREATE OR REPLACE TRIGGER TIBD_USER
2 BEFORE DELETE ON SYSTEM_USER FOR EACH ROW
3 DECLARE
4 FOUND_USER NUMBER(2);
5 BEGIN
6 SELECT COUNT(*) FROM ALL_USERS
7 WHERE USERNAME = :OLD.USER_ID;
8 IF FOUND_USER = 0 THEN
9 DELETE FROM SYSTEM_USER
10 WHERE ROWID := :NEW.ROWID;
11 ELSE
12 RAISE_APPLICATION_ERROR(-20000,'USER FOUND IN ALL_USERS TABLE');
13 END IF;
14 END TIBD_USER;
15 /
Warning: Trigger created with compilation errors.
SQL> SHOW ERRORS
Errors for TRIGGER TIBD_USER:
LINE/COL ERROR
7/1 PL/SQL: SQL Statement ignored
8/13 PL/SQL: ORA-00920: invalid relational operator
ANY HELP PLEASE1 CREATE OR REPLACE TRIGGER TIBD_USER
2 BEFORE DELETE ON SYSTEM_USER FOR EACH ROW
3 DECLARE
4 FOUND_USER NUMBER(2);
5 BEGIN
6 SELECT COUNT(*) INTO FOUND_USER FROM ALL_USERS
7 WHERE USERNAME = :OLD.USER_ID;
8 IF FOUND_USER = 0 THEN
9 DELETE FROM SYSTEM_USER
10 WHERE ROWID = :OLD.ROWID;
11 ELSE
12 RAISE_APPLICATION_ERROR(-20000,'USER FOUND IN ALL_USERS TABLE');
13 END IF;
14* END TIBD_USER;
SQL> /
Trigger created.
WHEN I DELETE A RECORD IT IS GIVING ME THAT
SQL> DELETE FROM SYSTEM_USER
2 WHERE CTUT_ID = 3;
DELETE FROM SYSTEM_USER
ERROR at line 1:
ORA-04091: table SYSTEM_USER is mutating, trigger/function may not see it
ORA-06512: at "TIBD_USER", line 7
ORA-04088: error during execution of trigger 'TIBD_USER' -
Hi,
I got a question using triggers. I have a statement level delete trigger that calls a package function used to insert data into various archiving tables. In order to keep track of the deleted rows I have a row level delete trigger that keeps the deleted Ids of my objects in a special table that I later query in my statement level trigger.
My main problem is that while all triggers are called properly and data is removed from desired tables, the data that should be inserted into my archiving tables does not appear until the trigger is fired again it appears. I don't really see what could cause data to be deleted and effectively removed while the data i want to insert does not appear until the next time the trigger is fired.
could it be that i need to explicitely commit the inserted data ?
If it's not clear, I could always post some of the code used.
Thanks,
GregSure (I hope it won't be too messy though).
---- PACKAGE DEF.
I have a package variable defined as follows:
TYPE idTable IS TABLE OF NUMBER(19) INDEX BY BINARY_INTEGER;
And my variables:
del_oldRows idTable;
del_emptyRows idTable;
---- PACKAGE BODY
In the body I have calls like this:
PROCEDURE delete_transaction(aID NUMBER) IS
BEGIN
-- I) Add New Data into appropriate archiving tables
-- 1) Many-to-Many Table for first object
INSERT ALL INTO X_OBJ1_OBJ2_DLTD
DLTD_ID,
OBJ1_ID,
OBJ2_ID
SELECT
ID,
OBJ1_ID,
OBJ2_ID
FROM X_OBJ1_OBJ2
WHERE (X_OBJ1_OBJ2.ID = aID )
-- 2) Second object <SNIP>
-- 1) Many-to-Many Table for first object
DELETE FROM X_OBJ1_OBJ2
WHERE (X_OBJ1_OBJ2.ID = aID );
END delete_transaction;
---- Before Delete Trigger (Statement Level)
This one resets the package in a consistent state:
BEGIN
mypackage.del_oldRows := mypackage.del_gatetrans_emptyRows;
END;
---- After Delete Trigger (Row Level)
This one adds Ids in my package variable:
BEGIN
mypackage.del_oldRows(mypackage.del_oldRows.COUNT + 1) := :OLD.ID;
END;
---- After Delete Trigger (Statement)
This one goes through each row in my package "table" and calls the function to add the related data in my archiving table:
BEGIN
FOR i IN 1 .. mypackage.del_oldRows.COUNT LOOP
mypackage.delete_transaction(mypackage.del_oldRows(i));
END LOOP;
mypackage.del_oldRows := mypackage.del_emptyRows;
END;
---- END
Anyways that's the basic logic. Kinda what is suggested for mutating tables when playing with UPDATE triggers I guess. Here it's just because I want my triggers to be simple and focus on inserting the archiving data for the object triggering the... trigger while related objects that need to be archived should be taken care of in my package function. My problem is that the data is removed properly but not appears as inserted until the next time the trigger is fired, as if i was always "one" trigger late :(.
If it's not clear enough, please let me know.
Thanks,
Greg -
Delete trigger not working on delete button
I have a form (parent) / report (children) combo page with all the default buttons (create, apply changes, delete, cancel) created from the wizard. I've created a before delete trigger on the parent table that basically finds all the children and deletes them. For debugging purposes, I've added some inserts into a test table to make sure my bind variables binding correctly (they are). When I confirm the java script delete and say ok, the insertion of the text for debugging purposes works fine, but the actual deletion of the other records does not. Any ideas why?
Then it is easy-your delete process is not fireing!!
Why...there may be many reasons....but I'm pretty sure that process is never fired!
Look in your page or show us a demo on workspace -
Newbie Trigger question - before delete
We have a table A - Primary Key A1, and Table B has a column B1 foreign key to A1 column.
We need to mass delete table A records which are more than 3 months old, but we do not want to delete Records from Table B, just nullify the foreign key column in table B.
So "ON DELETE CASCADE" is not applicable in our situation. Is creating a trigger with before delete option the only way to solve the above?
If yes, when inside the trigger action, how can I access the table A primary key value to find out if I have a possible match in table B? How to represent (current rows's A1 value) ?
For example - trigger action
CREATE TRIGGER DEL_A
BEFORE DELETE ON A
FOR EACH ROW
DECLARE X;
BEGIN
SELECT COUNT(*) INTO X
FROM B WHERE B1 = (current row's A1 value);
IF X > 0
THEN
UPDATE B SET B1 = NULL
WHERE B WHERE B1 = (current row's A1 value);
END IF;
ENDIs the above code correct, or is there any better way to do the same?
Thanks in advance,
Rumpawhere B1 = :A1
You probably mean "where b1 = :old.a1" ...
Regards,
Rob. -
:NEW cannot be used in After Delete Trigger ?
Hi,
Is there any way to get the :NW.value in the After delete trigger for each row. My requirement is audit log of the end user DML operations along with user Name (HERE THE USER IS NOT THE ORACLE USER, BECAUSE OF THE LARGE NUMBER OF END USERS WE ARE MAINTAINING ONE TABLE TO CREATE USER NAME & PASSWORD, WHEN THE USER LOGIN TO ORACLE FORM SCREEN, ASSIGN THE USER NAME TO GLOBAL VARIABLE) & Action Date.
Here is my code for trigger - It is working fine with INSER & UPDATE but for DELETE User is NULL
CREATE OR REPLACE TRIGGER Tgr_stud_det
AFTER INSERT OR UPDATE OR DELETE ON student_details
FOR EACH ROW
DECLARE
BEGIN
IF Inserting THEN
-------------INSERT VALUE---------------
INSERT INTO Log_student_details
(Seq,
App_User,
Action,
Action_Date,
stud_name,
stud_age,
stud_sex)
VALUES
(stud_sequence.NEXTVAL,
:NEW.App_User,
'INSERT',
SYSDATE,
:NEW.stud_name,
:NEW.stud_age,
:NEW.stud_sex);
-------------DELETE VALUE---------------
ELSIF Deleting THEN
INSERT INTO Log_student_details
(Seq,
App_User,
Action,
Action_Date,
Comment_Up,
stud_name,
stud_age,
stud_sex)
VALUES
(stud_sequence.NEXTVAL,
:OLD.App_User,
'DELETE',
SYSDATE,
NULL,
:OLD.stud_name,
:OLD.stud_age,
:OLD.stud_sex);
ELSIF Updating THEN
-------------UPDATE VALUE---------------
INSERT INTO Log_student_details
(Seq,
App_User,
Action,
Action_Date,
Comment_Up,
stud_name,
stud_age,
stud_sex)
VALUES
(stud_sequence.NEXTVAL,
:NEW.App_User,
'UPDATE',
SYSDATE,
'NEW VALUE',
:NEW.stud_name,
:NEW.stud_age,
:NEW.stud_sex);
INSERT INTO Log_student_details
(Seq,
App_User,
Action,
Action_Date,
Comment_Up,
stud_name,
stud_age,
stud_sex)
VALUES
(stud_sequence.CURRVAL,
:NEW.App_User,
'UPDATE',
SYSDATE,
'OLD VALUE',
:OLD.stud_name,
:OLD.stud_age,
:OLD.stud_sex);
END IF;
EXCEPTION
WHEN OTHERS THEN
NULL;
END Tgr_stud_det;
Thanks in advance.Rizly,
As i mentioned in the above post, you should remove the references of :old and :new when you are trying to use the global variables. These values are only significant when you the talk about the record in the table.
For the scenario, you explained, your trigger would insert two records....The trigger would be fired twice.. once during the insert and once during the delete. The audit table will have two records indicating both the actions..
Take a look at this example below...I am artificially manufacturing a user id in the package test_pkg and using that in the insert trigger. As i explained above, you dont need the :old and :new references because the user id is not a column in the table . hence the :old and :new references have no relevance.
Also note that, for the delete, I use the :old value and for the insert, I use the :new value.
for update, I assume you want to store the old record and hence used :old (you can of course use :new too..technically.).
I don't have access to a forms environement, but the user id logic should be similar to what I described below.
sql> create table t(
2 id number,
3 name varchar2(20)
4 );
Table created.
sql> create table t_audit
2 ( id number,
3 name varchar2(20),
4 action varchar2(20),
5 user_id varchar2(20)
6 );
Table created.
sql> create or replace package test_pkg as
2 function get_user_id return varchar2;
3 end test_pkg;
4 /
Package created.
sql> create or replace package body test_pkg as
2 function get_user_id return varchar2 is
3 begin
4 return 'USER' || to_char(sysdate,'HH24:MI');
5 end get_user_id;
6 end test_pkg;
7 /
Package body created.
1 create or replace trigger trg_biud_t
2 before insert or update or delete on t
3 for each row
4 begin
5 if INSERTING then
6 insert into t_audit values (:new.id, :new.name, 'INSERT',test_pkg.get_user_i
7 elsif UPDATING then
8 insert into t_audit values (:old.id, :old.name, 'UPDATE',test_pkg.get_user_i
9 elsif DELETING then
10 insert into t_audit values (:old.id, :old.name, 'DELETE',test_pkg.get_user_i
11 end if;
12* end;
sql> /
Trigger created.
sql> select * from t;
no rows selected
sql> select * from t_audit;
no rows selected
sql> insert into t values (100, 'Rajesh');
1 row created.
sql> insert into t values (200,'Kumar');
1 row created.
sql> delete from t where id = 200;
1 row deleted.
sql> commit;
Commit complete.
sql> select * from t
2 /
ID NAME
100 Rajesh
sql> select * from t_audit;
ID NAME ACTION USER_ID
100 Rajesh INSERT USER15:36
200 Kumar INSERT USER15:36
200 Kumar DELETE USER15:37 -
Before Report Trigger Running Endlessly
Hi all,
I got the following query in my before report trigger. But the system is running endlessly without stop. Any advise is appreciated.
function AfterReport return boolean is
begin
delete chart_temp;
COMMIT;
IF :P_1 IS NOT NULL THEN
INSERT INTO CHART_TEMP VALUES ( :PERIOD1, :M1 );
ELSE
IF :P_2 IS NOT NULL THEN
INSERT INTO CHART_TEMP VALUES ( :PERIOD2, :M2 );
END IF;
END IF;
COMMIT;
return (TRUE);
end;
rgds
LimRules-wise, you have the beforeReport trigger before the dataStructure, and that is correct. Syntax, the parameter is going in okay. Question is then the logic or data. Does the function work outside of this? That is, if you were to exec the function in an anonymous block of PL/SQL, do you get the desired output (i.e., test for boolean value returned)?
-
Error while using Before report trigger. -- Urgent
Dear All,
The following error I am getting when I execute my data template where I have used Before Report Trigger. I am also pasting the Data Template that I have developed.
============================
Error
============================
XDO Data Engine Version No: 5.6.3
Resp: 20560
Org ID : 204
Request ID: 4846248
All Parameters: P_LOB=01:P_DIV_FROM=:P_DIV_TO=:P_FROM_ORG=:P_TO_ORG=:P_INV_FROM=:P_TO_INV=:P_TRX_DATE_FROM="2003/01/01 00:00:00":P_TRX_DATE_TO="2003/01/15 00:00:00"
Data Template Code: SSBWIPANA_MFGR
Data Template Application Short Name: WIP
Debug Flag: N
{P_DIV_FROM=, P_TRX_DATE_TO=2003/01/15 00:00:00, P_DIV_TO=, P_FROM_ORG=, P_TO_ORG=, P_TRX_DATE_FROM=2003/01/01 00:00:00, P_INV_FROM=, P_LOB=01, P_TO_INV=}
Calling XDO Data Engine...
[122407_011745100][][EXCEPTION] SQLException encounter while executing data trigger....
java.sql.SQLException: ORA-06550: line 2, column 12:
PLS-00302: component 'P_LOB' must be declared
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
ORA-06550: line 3, column 12:
PLS-00302: component 'P_DIV_FROM' must be declared
ORA-06550: line 3, column 1:
PL/SQL: Statement ignored
ORA-06550: line 4, column 12:
PLS-00302: component 'P_DIV_TO' must be declared
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored
ORA-06550: line 5, column 12:
PLS-00302: component 'P_FROM_ORG' must be declared
ORA-06550: line 5, column 1:
PL/SQL: Statement ignored
ORA-06550: line 6, column 12:
PLS-00302: component 'P_TO_ORG' must be declared
ORA-06550: line 6, column 1:
PL/SQL: Statement ignored
ORA-06550: line 7, column 12:
PLS-00302: component 'P_FROM_INV' must be declared
ORA-06550: line 7, column 1:
PL/SQL: Statement ignored
ORA-06550: line 8, column 12:
PLS-00302: component 'P_TO_INV' must be declared
ORA-06550: line 8, column 1:
PL/SQL: Statement ignored
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)
at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215)
at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:967)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3327)
at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3433)
at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4394)
at oracle.apps.xdo.dataengine.XMLPGEN.executeTriggers(XMLPGEN.java:699)
at oracle.apps.xdo.dataengine.XMLPGEN.processData(XMLPGEN.java:254)
at oracle.apps.xdo.dataengine.XMLPGEN.processXML(XMLPGEN.java:205)
at oracle.apps.xdo.dataengine.XMLPGEN.writeXML(XMLPGEN.java:237)
at oracle.apps.xdo.dataengine.DataProcessor.processData(DataProcessor.java:364)
at oracle.apps.xdo.oa.util.DataTemplate.processData(DataTemplate.java:236)
at oracle.apps.xdo.oa.cp.JCP4XDODataEngine.runProgram(JCP4XDODataEngine.java:293)
at oracle.apps.fnd.cp.request.Run.main(Run.java:157)
=====================================================
Data Template
====================================================
<dataTemplate name="SSBWIPANA_MFGR" defaultPackage="PRODUCTION" version="1.0">
<parameters>
<parameter name="P_LOB" datatype="charecter"/>
<parameter name="P_DIV_FROM" datatype="charecter"/>
<parameter name="P_DIV_TO" datatype="charecter"/>
<parameter name="P_FROM_ORG" datatype="charecter"/>
<parameter name="P_TO_ORG" datatype="charecter"/>
<parameter name="P_FROM_INV" datatype="charecter"/>
<parameter name="P_TO_INV" datatype="charecter"/>
<parameter name="P_TRX_DATE_FROM" datatype="charecter"/>
<parameter name="P_TRX_DATE_TO" datatype="charecter"/>
</parameters>
<dataQuery>
<sqlStatement name="Q_1">
<![CDATA[SELECT DISTINCT MSI.CONCATENATED_SEGMENTS, MMT.INVENTORY_ITEM_ID,
MSI.DESCRIPTION, MMT.TRANSACTION_UOM, SDT.TRX_DATE,
MTP.ORGANIZATION_CODE, MMT.ORGANIZATION_ID
FROM MTL_MATERIAL_TRANSACTIONS MMT,
MTL_PARAMETERS MTP,
MTL_SYSTEM_ITEMS_VL MSI,
SSBWIP_DATE_TEMP SDT
WHERE MMT.INVENTORY_ITEM_ID = MSI.INVENTORY_ITEM_ID
AND MMT.ORGANIZATION_ID = MSI.ORGANIZATION_ID
AND MSI.ORGANIZATION_ID = MTP.ORGANIZATION_ID
AND MMT.ORGANIZATION_ID = MTP.ORGANIZATION_ID
AND MMT.TRANSACTION_TYPE_ID IN (17, 44)
AND MMT.ORGANIZATION_ID IN (
SELECT MP.ORGANIZATION_ID
FROM MTL_PARAMETERS MP, GL_CODE_COMBINATIONS GCC
WHERE MP.MATERIAL_ACCOUNT = GCC.CODE_COMBINATION_ID
AND GCC.SEGMENT1 = :P_LOB
AND (GCC.SEGMENT2 BETWEEN NVL (:P_DIV_FROM,
GCC.SEGMENT2)
AND NVL (:P_DIV_TO, GCC.SEGMENT2)
AND MTP.ORGANIZATION_CODE BETWEEN NVL (:P_FROM_ORG,
MTP.ORGANIZATION_CODE
AND NVL (:P_TO_ORG,
MTP.ORGANIZATION_CODE
AND MSI.CONCATENATED_SEGMENTS BETWEEN NVL
(:P_FROM_INV,
MSI.CONCATENATED_SEGMENTS
AND NVL
(:P_TO_INV,
MSI.CONCATENATED_SEGMENTS
ORDER BY MSI.CONCATENATED_SEGMENTS, MTP.ORGANIZATION_CODE]]>
</sqlStatement>
<sqlStatement name="Q_2">
<![CDATA[SELECT NVL (SUM (TRANSACTION_QUANTITY), 0) COMPLETION
FROM MTL_MATERIAL_TRANSACTIONS
WHERE INVENTORY_ITEM_ID = :INVENTORY_ITEM_ID
AND ORGANIZATION_ID = :ORGANIZATION_ID
AND TRANSACTION_TYPE_ID = 44
AND TRUNC (TRANSACTION_DATE) = :TRX_DATE]]>
</sqlStatement>
<sqlStatement name="Q_3">
<![CDATA[SELECT NVL (SUM (TRANSACTION_QUANTITY) * -1, 0) INCOMPLETION
FROM MTL_MATERIAL_TRANSACTIONS
WHERE INVENTORY_ITEM_ID = :INVENTORY_ITEM_ID
AND ORGANIZATION_ID = :ORGANIZATION_ID
AND TRANSACTION_TYPE_ID = 17
AND TRUNC (TRANSACTION_DATE) = :TRX_DATE]]>
</sqlStatement>
<sqlStatement name="Q_4">
<![CDATA[SELECT DESCRIPTION
FROM FND_FLEX_VALUES_VL
WHERE FLEX_VALUE_SET_ID = 1002470
AND FLEX_VALUE = :P_LOB]]>
</sqlStatement>
<sqlStatement name="Q_5">
<![CDATA[SELECT DESCRIPTION
FROM FND_FLEX_VALUES_VL
WHERE FLEX_VALUE_SET_ID = 1012471
AND FLEX_VALUE = :P_DIV_FROM
AND PARENT_FLEX_VALUE_LOW = :P_LOB]]>
</sqlStatement>
<sqlStatement name="Q_6">
<![CDATA[SELECT DESCRIPTION
FROM FND_FLEX_VALUES_VL
WHERE FLEX_VALUE_SET_ID = 1012471
AND FLEX_VALUE = :P_DIV_TO
AND PARENT_FLEX_VALUE_LOW = :P_LOB]]>
</sqlStatement>
</dataQuery>
<dataTrigger name="beforeReport" source="PRODUCTION.beforereporttrigger(:P_TRX_DATE_FROM,:P_TRX_DATE_TO)"/>
<dataStructure>
<group name="G_CONCATENATED_SEGMENTS" source="Q_1">
<element name="CONCATENATED_SEGMENTS" datatype="charecter" value="CONCATENATED_SEGMENTS"/>
<element name="DESCRIPTION" datatype="charecter" value="DESCRIPTION"/>
<element name="TRANSACTION_UOM" datatype="charecter" value="TRANSACTION_UOM"/>
<element name="INVENTORY_ITEM_ID" datatype="number" value="INVENTORY_ITEM_ID"/>
<element name="ORGNIZATION_ID" datatype="number" value="ORGANIZATION_ID"/>
<group name="G_TRX_DATE" source="Q_1">
<element name="TRX_DATE" datatype="date" value="TRX_DATE"/>
<group name="G_1" source="Q_1">
<element name="ORGANIZATION_CODE" datatype="charecter" value="ORGANIZATION_CODE"/>
<group name="G_ORGANIZATION_CODEC" source="Q_2">
<element name="COMPLETION" datatype="number" value="COMPLETION"/>
</group>
<group name="G_ORGANIZATION_CODEI" source="Q_3">
<element name="INCOMPLETION" datatype="number" value="INCOMPLETION"/>
</group>
</group>
</group>
</group>
<group name="G_LOB" source="Q_4">
<element name="CF_LOB" datatype="charecter" value="description"/>
</group>
<group name="G_FROM_DIV" source="Q_5">
<element name="CF_DIVFROM" datatype="charecter" value="description"/>
</group>
<group name="G_TO_DIV" source="Q_6">
<element name="CF_DIVTO" datatype="charecter" value="descrption"/>
</group>
<element name="CS_COUNT" function="count()" datatype="number" value="G_CONCATENATED_SEGMENTS.CONCATENATED_SEGMENTS"/>
</dataStructure>
</dataTemplate>
Pls. suggest me.
nullHi,
without checked the whole document .... you've defined all paramaters as datataype charecter instead of character.
Regards
Rainer -
INSERTstatement is not working if there is a before insert trigger
INSERTstatement is not working if there is a before insert trigger on that table. That trigger contains an insert to another table which having the main table reference.
Let us say, for example there a table named 'EMP_DEPT' and there is a before insert trigger on this table.
In this trigger inserting a record in to another table named 'AUDIT_EMP' and in this table using EMP_Dept primary key as foreign key.
Table EMP_DEPT is having the below columns:
EMP_DEPT_SYS_ID
EMP_DEPT_NO
DEP_NAME etc..
Table AUDIT_EMP is having the below columns:
AUDIT_EMP_SYS_ID
EMP_DEPT_SYS_ID
AUDIT_NO etc..
the code in the trigger is
INSERT INTO audit_emp
(audit_emp_sys_id, emp_dept_sys_id, audit_no
VALUES (audit_emp.NEXTVAL, :new EMP_DEPT_SYS_ID, '1101'
Now when you execute the insert query like:
INSERT INTO emp_dept
(emp_dept_sys_id, emp_dept_no, dep_name
VALUES (EMP_DEPT.nextval, 1001, 'Dep-1'
It is giving the error saying 'Integrity constraint error, parent key not found' from the trigger.
But, when you modify the above insert query like the below then it is working.
INSERT INTO emp_dept
(emp_dept_sys_id, emp_dept_no, dep_name
SELECT EMP_DEPT.nextval, 1001, 'Dep-1'
FROM DUAL;
I am using Oracle 10g.
Why the insert into values is not working. Is there any commit transaction sequence change? Any idea please?
Edited by: user6475632 on Sep 16, 2009 7:08 AMObviously the code you posted can not work.
You are inserting the detail record (the audit record) before the master record, where it should have been after. IMO, you should fire the trigger AFTER INSERT for each row.
If that still doesn't work, you need to change the foreign key constraint into a deferred constraint, which is evaluated at commit, instead of immediately. The SQL reference manual has further info on this.
'Oracle 10g' is considered a marketing label here, not a -4 digit- version.
Sybrand Bakker
Senior Oracle DBA -
Before Update Trigger has mutating problem
I'm getting a mutating problem with this updating trigger. I'm not sure how to deal with it. Here is my code:
CREATE OR REPLACE TRIGGER WTL_SMP_TRG2
BEFORE UPDATE ON WTL_SAMPLES
FOR EACH ROW
DECLARE
sampleCount NUMBER(1) := 0;
dupLabSampleID NUMBER(8) := 0;
BEGIN
SELECT COUNT(sample_ID)
INTO sampleCount
FROM wtl_samples
WHERE jb_job_id = :new.jb_job_id
AND lab_no = :new.lab_no
AND sample_ID != :old.sample_ID;
IF sampleCount > 0 THEN
SELECT sample_ID
INTO dupLabSampleID
FROM wtl_samples
WHERE jb_job_id = :new.jb_job_id
AND lab_no = :new.lab_no
AND sample_ID != :old.sample_ID;
RAISE_APPLICATION_ERROR(-20501, 'Update failed, Lab Number ' || :new.lab_no || ' is used by SampleID: ' || dupLabSampleID);
END IF;
--EXCEPTION
-- WHEN OTHERS THEN
-- RAISE_APPLICATION_ERROR(-20901, 'Error in WTL_SMP_TRG2.');
END WTL_SMP_TRG2;
any help appreciated
adamI guess I couldve done that, but was using design editor and didn't know how to put a unique constraint in. Is the problem only because I'm referencing the :old.sample_ID, or the :new values as well? If it's just the :old value I could write a before update statement trigger to place the sample_id into a package varaible and then call that variable up in the row level trigger.... i've tried this, but don't know how to pull the sample_id value i need in the before statement trigger... i'll supply the code i've done so far...
CREATE OR REPLACE TRIGGER WTL_SMP_TRG2_INIT
BEFORE UPDATE ON WTL_SAMPLES
DECLARE
BEGIN
wtl_trg_custom_pkg.oldSampleID := sample_id; /* Doesn't know sample_id...? */
END WTL_SMP_TRG2_INIT;
Maybe you are looking for
-
I am new to IPAD and I want o use facetime, how can I use it to communicate with my mac at home, do I need to create another account with a different email account
-
Creating a PDF from a SAAS app creates boxes instead of Japanese characters
I'm using an online app (Unleashed Software) to "print" invoices, and the printed invoices show boxes instead of Japanese characters. The really weird thing about this problem, is that it occurs only on certain devices. I've tested on Macs, Windows,
-
Problems converting pdf to word
adobe converts the pdf file to word fine except signs and symbols. How can I resolve this issue? help! BEFORE: AFTER: AFTER:
-
Hello, I'm having issues fixing my labview code to have an efficient response time. I tried multiple things to fix my issue, but can't seem to find a solution. I'm not as comfortable with LabVIEW as I am with other coding languages so troubleshooting
-
Flickering distortion when burning movies to DVD
I've noticed that regardless of the source of the movie/photos (digital, scanned, different cameras/camcorders) when the project is finished on a DVD and plays on TV (whether old-fashioned or HD) there are always some sections that have a flicker or