URGENT : Trigger
Hi,
I'm trying to write a trigger on a Table ROOM_BLOCK to update a value in table ROOM_OOI_OOS.
As given below, which works perfectly.
BEGIN
IF INSERTING THEN
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSIF UPDATING THEN
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSE
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
END IF;
END;
But when I add a select statement. the trigger seems to fail with a mutating error ORA-04091
and Error at Line which executes the statement immidiate ORA-04088.
DECLARE
stmt VARCHAR2(500);
vcount INTEGER;
BEGIN
IF INSERTING THEN
--INSERT INTO SHRUTI_TEST (DESCR) VALUES ('Inserting');
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
stmt := 'Select count(*) from ROOM_BLOCK ' ||
' WHERE ROOM_OOI_OOS_ID = ' || :NEW.ROOM_OOI_OOS_ID ||
' AND ROOM_NO = ''' || :NEW.ROOM_NO || ''' ';
EXECUTE IMMEDIATE stmt INTO vcount;
IF vcount = 1 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
END IF;
ELSIF UPDATING THEN
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSE
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
END IF;
END;
Please tell me how to solve this problem...
Regards
Mike.
Read the following link.
http://asktom.oracle.com/~tkyte/Mutate/index.html
Similar Messages
-
URGENT : Trigger with Mutating Error
Hi,
I'm trying to write a trigger on a Table ROOM_BLOCK to update a value in table ROOM_OOI_OOS.
As given below, which works perfectly.
BEGIN
IF INSERTING THEN
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSIF UPDATING THEN
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSE
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
END IF;
END;
But when I add a select statement. the trigger seems to fail with a mutating error ORA-04091
and Error at Line which executes the statement immidiate ORA-04088.
DECLARE
stmt VARCHAR2(500);
vcount INTEGER;
BEGIN
IF INSERTING THEN
--INSERT INTO SHRUTI_TEST (DESCR) VALUES ('Inserting');
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
stmt := 'Select count(*) from ROOM_BLOCK ' ||
' WHERE ROOM_OOI_OOS_ID = ' || :NEW.ROOM_OOI_OOS_ID ||
' AND ROOM_NO = ''' || :NEW.ROOM_NO || ''' ';
EXECUTE IMMEDIATE stmt INTO vcount;
IF vcount = 1 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
END IF;
ELSIF UPDATING THEN
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
IF NVL(:NEW.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)+1
WHERE ROOM_OOI_OOS_ID = :NEW.ROOM_OOI_OOS_ID;
END IF;
ELSE
IF NVL(:OLD.ROOM_OOI_OOS_ID,0) <> 0 THEN
UPDATE ROOM_OOI_OOS SET NO_OF_ROOMS = NVL(NO_OF_ROOMS,0)-1
WHERE ROOM_OOI_OOS_ID = :OLD.ROOM_OOI_OOS_ID;
END IF;
END IF;
END;
Please tell me how to solve this problem...
Regards
Mike.Thank you for your reply to my posting.
I researched and used your recommendation. I was
wondering if you can help me resolve the following two
problems.
Table kassa1 has NAME and AGE columns. Table Kassa2
has one column Age.
I have created the following trigger. It keeps
raising a ORA-06519 : Active autonomous transaction
detected and rolled back error.
Create or replace trigger Name_Age_Row after insert or
update on Kassa1
For each row
Declare
Total_Age VARCHAR(8);
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
Select SUM(Age) into Total_Age from Kassa1;
insert into kassa2 values(Total_aAge);
End;
The following trigger also generates ORA-00036:
Maximum number of recursive SQL levels(50) exceeded
error.
Create or replace trigger Name_Age_Row after insert or
update on Kassa1
For each row
Declare
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
insert into kassa1 values('newname', 'newage');
End; -
Regarding before insert and update trigger...Urgent!!
i have written a trigger to trim N upper the 1st field and trim N upper N replace period(.) for second field2 for future records.
When i compile, it says "complied with errors" is gives error as "insuffecient privlages"
Can anyone please figure out what problem is this??? And is my code correct?? if any changes to be done please let me know????
create or replace trigger TRG_test
before insert or update on test
for each row
declare
begin
:new.field1 := trim(upper(:new.field1));
:new.field2 := trim(upper(replace(:new.field2,'.' )));
end;
Urgent please!!!
Thank you in advance.The owner of the tables is User 2 and i am creating the trigger in user1 N i m calling this table from user2...as User2.TEST ...
User 1 as has previliges to acess the user 2 tables, since user2 tables are listed under user1 table section...
Do you system privilages????
I m using PL/SQL devloper tool.... -
...trigger issssue urgent
table cell
cell_id bscid
cellA bsc1
cellB bsc2
cellC bsc1
cellD bsc1
cellE bsc3
table irc
cell_id bsc
cellC ----
Now user will insert record in the table irc , and i want that bsc column should be filled automaticaly as user may not remember each cell's bsc..
following is the triiger i wrote
create or replace trigger T1
after insert on irc
for each row
declare
vbsc varchar2(10);
begin
select cell.bscid into vbsc from cell where cell.cell_id = irc.cell_id;
insert into irc ( bsc) values ( vbsc);
end;
THIS IS NOT WORKING AT ALL SHOWING ME A MESSAGE THAT
table of view does not exist.
THE Table do exist in USER A's table ..
i dont know what is happening..
kindly reply urgent
ALL I want is that wheneve user INSERT any row in IRC table .,
HE should not be allowed to insert BSCID , instead BSC ID should come up from a join and automatically fills in ..
thnx alot
regardsLook at this:SQL>CREATE TABLE cell
2 (
3 cell_id CHAR(5 CHAR),
4 bscid CHAR(4 CHAR)
5 );
Table created.
SQL>CREATE TABLE irc
2 (
3 cell_id CHAR(5 CHAR),
4 bsc CHAR(4 CHAR)
5 );
Table created.
SQL>INSERT INTO cell VALUES ('cellA' ,'bsc1');
1 row created.
SQL>INSERT INTO cell VALUES ('cellB' ,'bsc2');
1 row created.
SQL>INSERT INTO cell VALUES ('cellC' ,'bsc1');
1 row created.
SQL>INSERT INTO cell VALUES ('cellD' ,'bsc1');
1 row created.
SQL>INSERT INTO cell VALUES ('cellE' ,'bsc3');
1 row created.
SQL>COMMIT;
Commit complete.
SQL>SELECT * FROM cell;
CELL_ BSCI
cellA bsc1
cellB bsc2
cellC bsc1
cellD bsc1
cellE bsc3
SQL>CREATE OR REPLACE TRIGGER irc_trg
2 BEFORE INSERT ON irc
3 FOR EACH ROW
4 BEGIN
5 SELECT bscid INTO :NEW.bsc FROM cell WHERE cell_id=:NEW.cell_id;
6 END;
7 /
Trigger created.
SQL>INSERT INTO irc (cell_id) VALUES ('cellA');
1 row created.
SQL>COMMIT;
Commit complete.
SQL>SELECT * FROM irc;
CELL_ BSC
cellA bsc1Isn't it what you need?
Yoann. -
Need help in writin a trigger---Very Urgent
Help me in creating the trigger with below specifications.
"We want to reject record deletions where DATE_APPROVED_PROV is not null or NLA_PROV_DONE is not null
We want to reject updates where (DATE_APPROVED_PROV is not null or NLA_PROV_DONE is not null)
and
(any of CAPEX or RFS or ALLOCATIONS or DEPR_START_DATE is different before update than it would be after update)"
Defination of Table is below :
CREATE TABLE ir_data
(record_id NUMBER(12,0) NOT NULL,
request_title VARCHAR2(255),
cio VARCHAR2(30),
host_country VARCHAR2(20),
ben_project_name VARCHAR2(255),
application VARCHAR2(80),
req_summary VARCHAR2(500),
external_ref VARCHAR2(255),
submitted_by VARCHAR2(60),
approved_by_prov VARCHAR2(60),
date_approved_prov DATE,
approved_by_final VARCHAR2(60),
date_approved_final DATE,
nla_prov_done DATE,
nla_final_done DATE,
cost_alloc_method VARCHAR2(255),
capex NUMBER(12,0) DEFAULT 0,
allocations NUMBER(12,0) DEFAULT 0,
rfs NUMBER(12,0) DEFAULT 0,
ben_budget_id VARCHAR2(20),
delete_flag VARCHAR2(1),
amortisation NUMBER(12,0) DEFAULT 0
depr_start_date DATE,
fy_allocations NUMBER(12,0),
wusys VARCHAR2(1))Help me in creating the trigger with below
specifications.
"We want to reject record deletions where
DATE_APPROVED_PROV is not null or NLA_PROV_DONE is
not null
We want to reject updates where (DATE_APPROVED_PROV
is not null or NLA_PROV_DONE is not null)
and
(any of CAPEX or RFS or ALLOCATIONS or
DEPR_START_DATE is different before update than it
would be after update)"
Defination of Table is below :
CREATE TABLE ir_data
(record_id NUMBER(12,0) NOT
NULL,
request_title VARCHAR2(255),
cio VARCHAR2(30),
host_country VARCHAR2(20),
ben_project_name VARCHAR2(255),
application VARCHAR2(80),
req_summary VARCHAR2(500),
external_ref VARCHAR2(255),
submitted_by VARCHAR2(60),
approved_by_prov VARCHAR2(60),
date_approved_prov DATE,
approved_by_final VARCHAR2(60),
date_approved_final DATE,
nla_prov_done DATE,
nla_final_done DATE,
cost_alloc_method VARCHAR2(255),
capex NUMBER(12,0) DEFAULT
0,
allocations NUMBER(12,0)
DEFAULT 0,
rfs NUMBER(12,0)
DEFAULT 0,
ben_budget_id VARCHAR2(20),
delete_flag VARCHAR2(1),
amortisation NUMBER(12,0)
DEFAULT 0
depr_start_date DATE,
fy_allocations NUMBER(12,0),
wusys VARCHAR2(1))(any of CAPEX or RFS or ALLOCATIONS or DEPR_START_DATE is different before update than it would be after update)
I think if any of these change during an update do something. Not sure what. Probably reject, because that is what the other 2 requirements are.
Is this for an homework assignment?
Jim P. -
Help on Procedure and trigger for updating(urgent please)
SQL> / Table A
CTUT_ID CTUT_COMPANY_NAME CURRT_USER_ID FMIS_ID CREATE_DA UPDATE_BY UPDATE_DATE
1234 A 15-APR-03
2222 B 15-APR-03
3333 C 15-APR-03
4444 D 15-APR-03
5555 E 15-APR-03
6666 F 15-APR-03
150282 G oRACLE 23-APR-03
1 H 15-APR-03
2 I 15-APR-03
3 J 15-APR-03
150343 K TIGER 24-APR-03
150305 L EXAMPLE 23-APR-03
150342 M SCOTT 24-APR-03
sQL >/ Table B
Empno Empname UPDATE_BY UPDATE_DATE
1 AA
2 BB
3 CC
4 DD
What i need to do is i need to create an update trigger on both tables
like create a procedure
1)In procedure i need to check like
IF TABLEA.CURRT_USER_ID = (SELECT USER FROM DUAL)
THEN
UPDATE_BY = (CURRENT_USER_ID of CTUT_ID)
FOR EXAMPLE CURRENT USER_ID IS SCOTT THEN
UPDATE_BY = 150342
UPDATE_DATE = SYSDATE
ELSIF
UPDATE_BY <=> (CURRENT_USER_ID of CTUT_ID)
THEN
MESSAGE('USER IS NOT IN TABLE);
END IF;
and call that procedure in the update triggers
FOR BOTH TABLES TABLEA,TABLEB
i CREATED A PROCEDURE BUT IT IS NOT WORKING
ANY HELP PLEASE
CREATE OR REPLACE PROCEDURE UPDATE(
UPDATE_DATE out DATE,
UPDATE_BY out VARCHAR2)
IS
Uuser varchar2(20);
Udate date;
Ufound number(1);
BEGIN
SELECT USER,SYSDATE
INTO Uuser,Udate from dual;
SELECT count(*),CTUT_ID into Ufound,Uctut_id
FROM TABLEA
WHERE CURRT_USER_ID = Uuser
Group by Ctut_id;
IF (UFOUND = 1) THEN
UPDATE_DATE := UDATE;
UPDATE_BY := UCTUT_ID;
END IF;
EXCEPTION WHEN NO_DATA_FOUND THEN
RAISE_APPLICATION_ERROR(-20001,'User Does not Exist');
END UPD_CONSTITUENT;
CREATE A TRIGGER :
CREATE OR REPLACE TRIGGER TU
BEFORE INSERT ON TABLEA
FOR EACH ROW
BEGIN
UPDATE(:NEW.update_date,
:NEW.update_BY);
END IF;
END;
SQL> update TABLEA
2 set CTUT_COMPANY_NAME = 'SCOTT TEST'
3 WHERE FMIS_USER_ID = 'N';
update TABLEA
ERROR at line 1:
ORA-04091: table TABLEA is mutating, trigger/function may not see it
ORA-06512: at "UPDATE", line 12
ORA-06512: at "TU", line 1
ORA-04088: error during execution of trigger 'TU'Hi Mara,
You are right thats what i want
I have a table A
EmpNo Empname Currtuser_id Update_date Updateby
1 Denis Oracle
2 Scott Scott
3 Mara MMara
1)what i need to do is when any user tries to update the table Table A
Then the Trigger or procedure should check whether user is exits in table A in column currtuser_id
If his user id exits in table A
Then allow him to update the TABLE A
and insert his EMPNO in UPDATE_BY
and SYSDATE in UPDATE_BY
He will do all this process using forms
But i need to have trigger or procedure in database level for table
2) I have another table like 10 tables
Suppose TABLE B
When user tries to update TABLE B
Then the Trigger or procedure should check whether user is exits in table A in column currtuser_id
If his user id exits in table A
Then allow him to update the TABLE B
and insert his EMPNO in UPDATE_BY
and SYSDATE in UPDATE_BY
3) I need to have a common Procedure and call that procedure in all tables in UPDATE TRIGGER
Thanks for your help
Thanks -
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 -
[PLEASE] Prob with instead of Trigger [URGENT !]
Hi,
I have an INSTEAD OF TRIGGER on a view which update 2 based tables.
Each time the user update information,the system processes the update operation and insert a new row into the base tables.None of the based tables has any trigger.
Why this insertion occures ? How can i stop it and update only the based tables without inserting the same row ?
Thks for your advice
lamine
SQL> CREATE OR REPLACE TRIGGER UPDATE_PP_TR
SQL> INSTEAD OF UPDATE ON V_CONTACTS1_PP
SQL> FOR EACH ROW
SQL> begin
SQL> update ORGANIZATIONS
SQL> set
SQL> org_name = nvl(:new.org_name,org_name)
SQL> .....
SQL> ,updated_by = v('USER')
SQL> ,updated_date = sysdate
SQL> where org_id = :new.org_id;
SQL> update INDIVIDUALS
SQL> set
SQL> ,gender = nvl(:new.gender,gender)
SQL> ,first_name = nvl(:new.first_name,first_name)
SQL> ,last_name = nvl(:new.last_name,last_name)
SQL> ......
SQL> ,updated_by = v('USER')
SQL> ,updated_date = sysdate
SQL> where org_id = :new.org_id;
SQL> end UPDATE_PP_TR;Thks Andrew for your reply,
The INSTEAD OF trigger doesn't insert new row as i said before.... apologies.... It processes 2 things:
- update the field with the new value (what i want)
- Replace any existing data that has the same reference_key by the new value.
If we change the email of an individual and it happens that they are many people in the same company,then the INSTEAD OF TRIGGER updates the email and replace the other employees records by the one that has been updated.
But if the company employes only 1 person then the process is ok.It's bizarre only for many employees in the same company.
i.e:
Martin Tom , [email protected], FRANCE SOFT
Paul Henri, [email protected], FRANCE SOFT
Jason Case, [email protected], FRANCE SOFT
If i update Martin Tom's email to [email protected], Paul and Jason would be replace by Marin Tom's record....
Martin Tom , [email protected], FRANCE SOFT
Martin Tom , [email protected], FRANCE SOFT
Martin Tom , [email protected], FRANCE SOFT
Maybe my instead of trigger is written improperly.....
Any advise ? -
Regarding Procedure & Trigger (Plz Some one Help me... Its Urgent)
HI,
I think its a Big Message........ I dont know How many Will have patience in reading this...... Sorry for this Inconvience........
Iam having 4 tables:
3 Input table and 1 target table.
LOgic: Want to Load in the Target table From the input table Based on Some Criteria
Input Tables:
Table 1:Tbl_A
It has ID and Name
TBL_A
Ex: ID Name
201 Anu
202 Banu
203 Chitra
Table 2: Tbl_B
It has Name and Id
(The record of Column Name in this table should Contain the same Names of Tbl_A and id should be different from Table a)
TBl_B:
ID NAME
501 Anu
502 Banu
503 Chitra
Table 3: TBL_C
(It is independent on both Tbl_A and Tbl_b)
it has this Static records as Follows:
TBL_C
ID NAME
1 A
2 P
Output Table:
TBL_Target: ( It has 3 columns): ID,Source id, and Identifier
ID SRC_ID IDENTIFIER
LOgic:
For Loading data into Target tbl :TBL_Target
1. Procedure should have 'Name' of TBL_C as input parameter. So input will be
'A' or 'P'
*Based on the input Name from TBL_C the corresponding ID should be taken
from TBL_C and inserted into the ID Column of TBL_Target
EX: IF 'A' Then 1 Should be inserted . IF P means 2 should be inserted
2. we have to select the IDs from TBL_A and TBL_B based on Their Names as Join condition and insert the ID of TBL_A into IDENTIFIER Column of TBL_Target
and insert the ID of TBL_B into SRC_ID Column of TBL_Target
(Note: Actually We have to get the ID'S of all the rows from TBL_A and TBL_B based on their join Condition and load into Target table)
Out PUt: ( if the input of Procedure is 'A')
TBL_Target
ID SRC_ID IDENTIFIER
1 501 201
1 502 202
1 503 203
Out PUt: ( if the input of Procedure is 'P')
TBL_Target
ID SRC_ID IDENTIFIER
2 501 201
2 502 202
2 503 203
LOgic2:
I want to Write a Trigger So that Whenever Iam Inserting New Records in TBL_A
the Trigger should Call the Procedure We have Created
Thanks......Hi,
I created a Trigger based on After inserting.....
I called the Procedure inside the Trigger.....
Trigger is created. But While executing the trigger it Throws an error: Table is Mutating .Trigger or Function May not see it.
This is the procedure Created:
CREATE OR REPLACE PROCEDURE Proc_Load (Tblc_Name in Varchar2)
AS
-- VARIABLE AND CURSOR DECLARATION:
V_name Varchar2(100);
V_id_c number;
V_id_a number;
V_id_b number;
CURSOR cur_name IS SELECT a.id,b.id
FROM tbl_a a,tbl_b b WHERE TRIM(a.name)=TRIM(b.name);
begin
V_name:=Tblc_name;
SELECT id INTO V_id_c FROM Tbl_c WHERE name=V_name;
OPEN Cur_name;
LOOP
FETCH cur_name INTO V_id_a,V_id_b;
INSERT INTO tbl_target VALUES (V_id_c,V_id_b,V_id_a);
COMMIT;
EXIT WHEN (cur_name %NOTFOUND);
END LOOP;
CLOSE Cur_name;
END;
Trigger Created:
CREATE OR REPLACE TRIGGER Trig_name
AFTER INSERT ON TBL_A
FOR EACH ROW
BEGIN
Proc_Load ('A');
END;
If iam Executing trigger Error OCcurs Table is Mutating .Trigger or Function May not see it.
How to solve it? -
Need Urgent Help with trigger in Oracle 10g
Hello frd,
I am working on my DBMS Project in VB 6.0 that is Tollbooth management system
i have to insert one trigger for my project so i had decided to insert time trigger.
I have total 3 table UserLogin, Vehice and Vehicle_Data
the 3rd table Vehicle data contain the following fields
Vehicle_Type, Vehicle_No, Tax_Time, Source, Destination and Tax
Now i had done coding for tax when you select Vehicle Type, Source and Destination the Tax Field will automatically fillup and all the data will Saved in Oracle table but now my problem is that i want to create trigger for Tax_Time column When any new data inserted current time will stored in that column
I had create one but it gives error
create trigger time after insert on vehicle_Data
for each row
begin
insert into Vehicle_Data(Tax_Time) values(to_char(sysdate, 'HH:MI:SSAM DD_MON_YYYY'));
end;
Note: I am Using VB 6.0 and Oracle 10g Express EditionI had create one but it gives errorWelcome to the forum and many many thanks for not posting the full error message, that is really helpful, since we're all a 100% sure what's going on now (yes, that was ironic ;) ).
Let me guess: a mutating table error?
Read:
http://www.oracle-base.com/articles/9i/MutatingTableExceptions.php
http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551198119097816936
But before that, actually you should read:
http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html -
Urgent - After Insert Trigger is not working
CREATE OR REPLACE TRIGGER TD_ADD_SHIPPING_COST
AFTER INSERT ON wlcs_order
REFERENCING NEW AS new_order
FOR EACH ROW
BEGIN
IF (:new_order.order_id IS NOT NULL) THEN
-- call update_wlcs_order procedure from shipping_cost package
SHIPPING_COST.update_wlcs_order(:new_order.order_id);
END IF;
END TD_ADD_SHIPPING_COST;See my answer in your other posting here
Re: Calling of Stored Procedure in After Insert Trigger -
can we call an form (.fmx) or a report (.rep) from a database trigger. that is when there is some insertion in the table i want to call a report which will take the parameters from the table changed.
regards
vishalJDeveloper and ADF
-
Urgent!!!----Update a field of Long data type via trigger
While it is obvious that it is no way for an Oracle trigger to update a field of a Long data type, is it a feasible way to call a java stored procedure from the trigger to achieve that purpose? If not, can you suggest any good solution to this?
Thanks so much.Scripter -
When you try to do a Set and Put, it is always good to explicitly set the statement's cursor type to something other than forward only, like keyset, and the lock type to something other than read-only. See if that helps...
Scott Richardson
National Instruments -
URGENT: PO release flow doesnt trigger message to approver
Hi,
I have an urgent request for support. I copied the standard workflow WS20000075 to WS9950000013. The message to the first approver is triggered just fine. But upon setting the release, there is no message triggered to the next and last approver. Find below a screenshot of the SWEL log. I get an error message for the event SIGNIFICANTLYCHANGED: No configuration for workflow WS99500013 . In anotger system for another client I just activated the workflow and done. Don't know what causes the problem here since as far as I could see setup is the same in both systems
Any help appreciatedHi Joris,
First With template WS20000075 , SIGNIFICANTLYCHANGED event has been configured and I think this event will work only for the template WS20000075. In place of copying the template WS20000075 create a new versoin of this and change the template according to your need. SAP allows change in template WS20000075.
Second Please check whether any release stretgy change has been done ?
BR,
Prakash -
Trigger problem (urgent)
Here is my trigger. it doesnt give any error but it doesnt work.
the aim:
i have 2 tables and 1 view. (i cannot change this structure currently.)
Registered (student, course) --table
WaitingFor (student, course, regisdate) --table
DemandOfCourses (student, course, situation) -- view. situation is either REGISTERED or WAITING
if a student unregisters from a course, the student who is waiting in the queue (WaitingFor) should be inserted into the Registered table for that course. (Some courses have capacity limits, some of them dont.)
Actually, there is an error named 'no data found'. however, i solve it using the exception stated in the trigger.
after deleting someone, it says '1 row deleted', but i dont see any change in the table. it doesnt work.
for example:
DELETE FROM DEMANDOFCOURSES WHERE STUDENT = 100026 AND COURSE = 'BLE788';
1 row deleted.BUT NOT.. i hope someone can help me.. i am not able to solve it..
CREATE OR REPLACE TRIGGER DemandOfCourses_T2_ID
INSTEAD OF DELETE ON DemandOfCourses
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
stud NUMBER;
crs VARCHAR2(15);
stud2 NUMBER;
BEGIN
SELECT student, course
INTO stud, crs
FROM (SELECT * FROM WaitingFor ORDER BY regisdate)
WHERE course = :OLD.course
AND rownum=1;
-- check if the student who wants to delete his registration is really registered
SELECT student
INTO stud2
FROM Registered
WHERE student = :OLD.student
AND course = :OLD.course;
-- IF STUDENT IS REALLY REGISTERED, DELETE HIS REGISTRATION.
IF (stud2 IS NOT NULL) THEN
DELETE FROM Registered
WHERE student = :OLD.student
AND course = :OLD.course;
END IF;
-- IF SOMEBODY IS WAITING FOR THE COURSE, DELETE HIM FROM THE WAITING LIST AND REGISTER HIM AND.
-- OF COURSE, IN ORDER TO REALIZE THIS, THE STUDENT WHO WANTED TO BE DELETED FROM THE COURSE
-- SHOULD HAD BEEN REGISTERED FOR THE COURSE, THIS TEST IS DONE BY (stud2 IS NOT NULL) HERE.
IF (stud IS NOT NULL) AND (stud2 IS NOT NULL) THEN
BEGIN
DELETE FROM WaitingFor
WHERE student = stud
AND course = crs;
INSERT INTO Registered
VALUES (stud, crs);
END;
END IF;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;You can use the exceptions to decide whether or not to do the various operations.
I would write your trigger more like:
CREATE OR REPLACE TRIGGER demandofcourses_t2_id
INSTEAD OF DELETE ON demandofcourses
FOR EACH ROW
DECLARE
stud NUMBER;
crs VARCHAR2(15);
not_registered EXCEPTION;
BEGIN
-- Delete the registered student and check if we deleted a row
DELETE FROM registered
WHERE student = :old.student and
course = old.course;
IF SQL%ROWCOUNT = 0 THEN -- Nothing to delete so not registered
-- This will go to the EXCEPTION section at the bottom
RAISE not_registered;
END IF;
-- If we get here then the student was registered so
-- check if a student is waiting
-- If no student is waiting this will throw NO_DATA_FOUND and be caught
-- in the EXCEPTION BLOCK at the end
SELECT student, course
INTO stud, crs
FROM (SELECT * FROM waitingfor ORDER BY regisdate)
WHERE course = :OLD.course and
ROWNUM = 1;
-- If we get to here, then the student was registered, and there was
-- someone waiting so
DELETE FROM waitingfor
WHERE student = stud and
course = crs;
INSERT INTO registered
VALUES (stud, crs);
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN not_registered THEN
NULL;
END; HTH
John
Message was edited by:
John Spencer
Honestly, Warren's last example and everything that followed wasn't there when I posted.
Maybe you are looking for
-
My old laptop had all my music library on it and I have no back up. I have gotten a new laptop (a PC not MAC) and really need my music onto my iphone, please help!!
-
TS4000 I can't see my reminders in my Calendar app on my Mac (10.8.5)
Am I going mad??? Or do reminder lists not display in Calendar like they used to? I have looked on various discussions.... They suggest that reminders lists are displayable on the Calendar app But they seem separate apps now. I know I can see a calen
-
Message Header value is not written to DynamicConfiguration
Hi Forum, I have a scenario on a PI 7.11 SP06, where a SOAP message is sent via HTTP to a SAP WAS Java. The response contains in header a parameter"set-cookie" which has to be written in dynamic configuration. For example: Set-Cookie: JSESSIONID=DF4
-
Need Recovery Disks - Please Help!
Hello, I need the recovery disks for my "Lenovo 3000 N200" laptop as I can not create the disks myself. Problem is, when I tried to call Lenovo for the disks and pressed 2 for the 3000 support, "it didn't recognize my choice". I really need these dis
-
Hi there! Wanna see if you guys can help me out... Installed my versions of InDesign, Flash, Fireworks, Illustrator, Dreamweaver and Photoshop today. All of them worked out... except (there's always an exception, right?). My keyboard does not functio