Reg: pre loop insert trigger
HelloI have to write a loop in the notice for the sub condition.
I have a table called book_desc (B_Id, abb, abb_desc)
I have a value for one of the class like below:
: book_desc.abb: = 'SS, NS, PS, FRA ";
I have another table called abrivation_desc (code, desc)
code desc
Social studies SS
Science NS
Physical science PS
English ENG
Now I need to write a loop using this loop, I need to get the data as below:
: book_desc.abb_desc: = 'social studies, natural sciences, English, physical sciences;
This means that I need to insert data into book_desc as below
B_Id abb abb_desc
1 SS, NS, PS, human sciences, natural sciences, physical sciences English ENG
2 NS, PS Natural Science, physical sciences
3 NS, PS, natural sciences, sciences, English ENG
Thanks in advance
This works for me... Post your code here... and specify the place you call this procedure
Published by: Dora on January 21, 2010 08:06
Tags: Oracle Development
Similar Questions
-
Prior insertion trigger problem
Hi Guyz,
I am facing a strange problem or may be wrong somewhere, but can't find my problem, I hope I'll get the solution to my problem here im im.
IM updating my quantities in the table MN_ITEM_DETAILS.
I have below master-details on before insert trigger block works very well.SQL> DESC MN_ITEM_DETAILS Name Null? Type ----------------------------------------- -------- ------------------ SI_SHORT_CODE NUMBER(10) SI_CODE NUMBER(15) ITEM_DESCP VARCHAR2(200) ITEM_U_M VARCHAR2(6) ITEM_QTY NUMBER(10) ITEM_REMARKS VARCHAR2(100)
All the triggers to INSERT before & after INSERTION block levelSQL> DESC MN_MDV_MASTER Name Null? Type ----------------------------------------- -------- ---------------------------- MDV_NO NOT NULL NUMBER(15) MDV_DATE DATE WHSE_LOC VARCHAR2(15) PROJ_WHSE VARCHAR2(30) ACTIVITY_LOC VARCHAR2(30) MRF_NO VARCHAR2(30) CLIENT VARCHAR2(30) CLIENT_PO# VARCHAR2(15) CLIENT_PO_DATE DATE WHSE_INCHG VARCHAR2(30) WHSE_DATE DATE RECD_BY VARCHAR2(30) INSPECTED_BY VARCHAR2(30) DRIVER_NAME VARCHAR2(30) REMARKS VARCHAR2(200) RECD_BY_DATE DATE INSPECTED_DATE DATE DRIVER_NAME_DATE DATE CST_CENTER VARCHAR2(15) SQL> DESC MN_MDV_DETAILS Name Null? Type ----------------------------------------- -------- ---------------------------- MDV_NO NUMBER(15) ITEM_CODE NUMBER(15) ITEM_DESCP VARCHAR2(150) ITEM_U_M VARCHAR2(6) ITEM_QTY NUMBER(6) ITEM_BALANCE NUMBER(10) PROJECT VARCHAR2(15) ACTIVITY VARCHAR2(15) LOCATION VARCHAR2(15)
until the above works fine and its update of the MN_ITEM_DETAILS. ITEM_QTY correctlyPRE-INSERT -- ON details block level UPDATE MN_ITEM_DETAILS SET ITEM_QTY = NVL(ITEM_QTY,0) - NVL(:MN_MDV_DETAILS.ITEM_QTY,0) WHERE SI_CODE = :MN_MDV_DETAILS.ITEM_CODE; POST-INSERT MASTER BLOCK LEVEL TRIGGER INSERT INTO MN_MRBV_MASTER( MDV# , MDV_DATE , WHSE_LOC , CST_CENTER )VALUES (:MN_MDV_MASTER.MDV_NO , :MN_MDV_MASTER.MDV_DATE , :MN_MDV_MASTER.WHSE_LOC , :MN_MDV_MASTER.CST_CENTER); POST-INSERT ON DETAILS BLOCK LEVEL INSERT INTO MN_MRBV_DETAILS( MDV# , ITEM_CODE , ITEM_DESCP , ITEM_U_M , QTY , ITEM_BALANCE , PROJECT , ACTIVITY , LOCATION )VALUES (:MN_MDV_DETAILS.MDV_NO , :MN_MDV_DETAILS.ITEM_CODE , :MN_MDV_DETAILS.ITEM_DESCP , :MN_MDV_DETAILS.ITEM_U_M , :MN_MDV_DETAILS.ITEM_QTY , :MN_MDV_DETAILS.ITEM_BALANCE, :MN_MDV_DETAILS.PROJECT , :MN_MDV_DETAILS.ACTIVITY , :MN_MDV_DETAILS.LOCATION );
but im using the same as above in the MASTER-DETAIL table below but do not update the ITEM_QTY in MN_ITEM_DETAILS
SQL> DESC MN_MRBV_MASTER Name Null? Type ----------------------------------------- -------- ---------------------------- MDV# NOT NULL NUMBER(15) MDV_DATE DATE WHSE_LOC VARCHAR2(15) RET_FRM_PROJECT VARCHAR2(1) RET_FRM_CLIENT VARCHAR2(1) CST_CENTER VARCHAR2(15) WHSE_INCHG VARCHAR2(30) WHSE_DATE DATE RETURN_BY VARCHAR2(30) INSPECTED_BY VARCHAR2(30) RETURN_BY_DATE DATE INSPECTED_BY_DATE DATE DRIVER_NAME VARCHAR2(30) DRIVER_DATE DATE REMARKS VARCHAR2(250) SQL> DESC MN_MRBV_DETAILS Name Null? Type ----------------------------------------- -------- ---------------------------- MDV# NUMBER(15) ITEM_CODE NUMBER(15) ITEM_DESCP VARCHAR2(150) ITEM_U_M VARCHAR2(6) QTY NUMBER(6) ITEM_BALANCE NUMBER(10) PROJECT VARCHAR2(15) ACTIVITY VARCHAR2(15) LOCATION VARCHAR2(15)
ConcerningPRE-INSERT--> here its not updating the MN_ITEM_DETAILS.ITEM_QTY table any sugesstion plz why its not updating...? MDV_DETAILS UPDATE MN_ITEM_DETAILS SET ITEM_QTY = NVL(ITEM_QTY,0) + NVL(:MN_MRBV_DETAILS.QTY,0) WHERE SI_CODE = :MN_MRBV_DETAILS.ITEM_CODE;
Houda
Published by: houda Shareef on January 8, 2011 02:19try to write your code in before update trigger
-
Hello
I'm working on form of oracle 10g, and I get the following error when inserting a record: "FRM - 40735:PRE - INSERT-triiger raised unhandled exception ORA-06503"
When I remove the trigger for insertion prior to the field, the error record sace and cancel out successfully, here's the code for the previous insert trigger:
/ * To insert the Date and the user automatically * /.
DECLARE
vb_result BOOLEAN;
BEGIN
vb_result: = pkg.check_unique ('reference', 'ref_desc': reference.ref_desc, 'ref_type',:reference.ref_type, null, null, 2);
IF (vb_result = TRUE)
THEN
msg_alert ("Description already existing < ', 'E', TRUE");
END IF;
: reference.ref_cdate: = SYSDATE;
: reference.ref_cuser: = USER;
END;
can someone help me thanks
Published by: user11811876 on August 21, 2009 10:58Hello
ORA-06503 means you used a function but do not return a value of it.
You can actually use retrun in your function, but in some cases, in my view, is not there (especially in the case of exception).
Just checking your cil_pkg.check_unique function or even zip code here.
You missed a return statement somewhere inside.
It will be useful.
Check the answer as useful / OK, if this can help you
Carole
-
Redirect data to another table using before insert trigger.
Dear all,
How can I redirect the data to another table in a before Insert trigger? My database is Oracle10g.
I have a table EMP (EMP_ID, LAST_NAME, SALARY).
I have another EMP_COPY table with the same structure. I also have a before Insert trigger on the EMP table.
Based on a condition that I have to redirect the data in table EMP_COPY. Let's say the condition is EMP_ID = 100.
I fire an insert on EMP table for example INSERT IN EMP(EMP_ID,LAST_NAME,SALARY) VALUES(100,'Dev',500).
On the inside of the front Insert trigger on the EMP table, I have the code
IF EMP_ID = 100 THEN
INSERT INTO EMP_COPY (EMP_ID, LAST_NAME, SALARY)
VALUES(:NEW.) EMP_ID,: NEW. LAST_NAME,: NEW. SALARY);
COMMIT;
ON THE OTHER
NULL;
END IF;
But the problem here is that data goes to EMP table of origin also although I don't want. He should do an Insert into EMP table only if EMP_ID! = 100.
One way has been to raise a user-defined exception inside the If statement and not handle it so that the original insert on table EMP fails but INSERT comes in the EMP_COPY table. But in this solution since the inside the trigger unhandled exception, it propagates to the calling environment. And I can't stand outside relaxation as the calling environment is a form of Oracle Apps standard that cannot be customized.
Any kind of help will be highly appreciated that I am fighting for more than two weeks.
Thanks in advance
DevRemove the autonomous transaction pragma... and then try again.
-
Parent - child Table Insert Trigger
Hello
I need assistance with an Insert trigger. I want to insert field data 'Table A' "Table B" based on a PK and FK. Someone at - it examples of code?
< code >
Table A
SEQ_NO - PK
TO FIELD
FIELD B
C FIELD
Table B
FK_SEQ_NO
FIELD B
C FIELD
< code >
When the data is stored in the 'table A' I need fill out the 'FK_SEQ_NO', based on the saved value 'Table A' "SEQ_NO" as well as the values of FIELD B and C FIELD recorded in Table B.
Any help is really appreciated, thank you.Hi Charles,
It depends exactly how you created your trigger.
In my trigger I fill WORK_PACKAGE_ID (PK) in the parent table using rmdb_work_packages_seq. NEXTVAL. The insert statement then uses: NEW. WORK_PACKAGE_ID to fill the coumn FK in table child.
You can also use ITEM_ID_SEQ. CURRVAL who will repeat the last number that was created, and I suppose that you use to fill A table.
Hope that helps,
Martin -
Hi, I try to put an event reminder Reg within a while loop where it need to be updated constantly and I have the following error:
"LabVIEW: (Hex 0x4A5) you can not record the same event on an object several times."
If I remove the while loop it works fine, but I need this loop. How to solve the problem?
Thank you
You register the event with the same VI reminder each time? You don't need to do. Once registered, the VI reminder will trigger on every triggered event.
You would only need to re - register the event if you want to switch to another reminder VI. To do this, you must first call Unregister for events on the first recorded event.
-
Before Insert TRIGGER to create partitions problem
Hello
I m having a problem with the following situation in Oracle 8i:
I have a table TEST_TABLE, which is divided by the beach with a DATE column. The idea is to have a partition for each month, so the HIGH_VALUE of partitions is always the first day of the month following that represents the partition.
I created a BEFORE TRIGGER INSERT on the table TEST_TABLE, which tests if the partition for the month of registration which is being inserted exists and, in case it doesn´t, a PROC AUTONOMOUS_TRANSACTION is called to create the TRIGGER.
Running the code below one can see that even if partitions are created as expected, when you try to insert a record with a date greater than the last partition for the first time, this error is returned:
ORA-14400: inserted partition key exceeds plu legal partition key.
Note that if you run the same statement again insert, it s inserted correctly on the partition that was created the first try.
I´ll appreciate any help on this matter.
code
----------------
CREATE TABLE TEST_TABLE)
IDENTIFICATION NUMBER,
DATE OF THE DT
)
TABLESPACE USERS
PARTITION BY RANGE (DT)
(
PART_B42009 PARTITION VALUES LESS THAN (TO_DATE ('2009-01-01 00:00:00 ',' YYYY-MM-DD HH24:MI:SS ',' NLS_CALENDAR = GREGORIAN '))
LOGGING
TABLESPACE USERS
);
/
CREATE OR REPLACE PROCEDURE SP_ADD_PARTITION (TEST_TABLE P_DATE. DT % TYPE)
IS
PRAGMA AUTONOMOUS_TRANSACTION;
V_STR VARCHAR2 (500);
BEGIN
V_STR: = 'ALTER TABLE TEST_TABLE ADD.
|| 'PARTITION BIRD | TO_CHAR ("P_DATE, ' YYYYMM")
|| ' VALUES LESS (TO_DATE ("')).
|| TO_CHAR (ADD_MONTHS (P_DATE, 1), "YYYY-MM"). '-01 00:00:00 ','
|| ((' SYYYY-MM-DD HH24:MI:SS "," NLS_CALENDAR = GREGORIAN "))';
EXECUTE IMMEDIATE (V_STR);
END SP_ADD_PARTITION;
/
CREATE OR REPLACE TRIGGER TR_B_I_R_TEST_TABLE
BEFORE INSERTING
ON TEST_TABLE FOR EACH LINE
DECLARE
NUMBER OF V_PARTITION_EXISTS;
BEGIN
IF: NEW. DT > = TO_DATE ('2009-01-01 00:00:00 ',' ' YYYY-MM-DD HH24:MI:SS) THEN
IMMEDIATELY EXECUTE (' SELECT COUNT (1) ")
|| "Of all_tab_partitions atp'."
|| "WHERE atp.table_name ="table_test"'.
|| "AND the atp. Nom_partition =: v1 ')
IN V_PARTITION_EXISTS
WITH THE HELP OF "BIRD" | TO_CHAR(:NEW.) "DT,"YYYYMM";)
IF V_PARTITION_EXISTS = 0 THEN
DBMS_OUTPUT. Put_line ('Partition [' |]) 'BIRD ' | TO_CHAR(:NEW.) "DT,"YYYYMM"). does not exist!') ;
DBMS_OUTPUT. Put_line ('creation..');
SP_ADD_PARTITION (: NEW.) DT);
DBMS_OUTPUT. Put_line ('success.');
IMMEDIATELY EXECUTE (' SELECT COUNT (1) ")
|| "Of all_tab_partitions atp'."
|| "WHERE atp.table_name ="table_test"'.
|| "AND the atp. Nom_partition =: v1 ')
IN V_PARTITION_EXISTS
WITH THE HELP OF "BIRD" | TO_CHAR(:NEW.) "DT,"YYYYMM";)
IF V_PARTITION_EXISTS = 1 THEN
DBMS_OUTPUT. Put_line ("it s visible at this point..");
ON THE OTHER
DBMS_OUTPUT. Put_line ("it s not visible at this point..");
END IF;
ON THE OTHER
DBMS_OUTPUT. Put_line ('Partition [' |]) 'BIRD ' | TO_CHAR(:NEW.) DT, "YYYYMM")
|| already exists! ") ;
END IF;
END IF;
DBMS_OUTPUT. Put_line ('continues with insertion...");
END TR_B_I_R_TEST_TABLE;
/
-Go to the low score
INSERT INTO TABLE_TEST VALUES (1, TO_DATE ('2008-12-31 23:59:59 ',' YYYY-MM-DD HH24:MI:SS'));))
-Returns the error on the first try
INSERT INTO TABLE_TEST VALUES (2, TO_DATE ('2009-01-01 00:00:01 ',' YYYY-MM-DD HH24:MI:SS'));))
----------------It is the use of the pragma AUTONOMOUS TRANSACTION. Your current transaction cannot see the result of this DOF since it occurs outside of the current transaction. The clue is in the name.
Of course, you cannot run the DDL in a trigger without use of this pragma, so you're pretty much stuck. There is a solution in 11g, but that will not help you. Unfortunately, your only option is to pre-create the partitions required in front of the need. For example, you might have a DBMS JOB to create a partition for the next month, which takes place the last day of each month (or logical date of company).
Cheers, APC
blog: http://radiofreetooting.blogspot.com
-
Make required error appears only the primary key generated in prior Database Table insert trigger
Dear all,
I am a beginner in the ADF and am under Jdeveloper Studio Edition Version 12.2.1.0.0.
I'm trying to insert a record, I created the trigger for insertion prior to get the primary key and set some other default values.
On the page, I did read-only primary key column and false required.
When I try to save - commit (Programmatic), I get errors for the required value. How can I stop this errors.
Secondly, I also tried changing the agent to disabled on the attribute View object that raised the error below:
< oracle.dfw.impl.incident.DiagnosticsDataExtractorImpl > < DiagnosticsDataExtractorImpl > < createADRIncident > < incident created 148 to key problem "DFW-99998 [oracle.jbo.PersistenceException] [oracle.jbo.server.RowReference.verifyPrimaryKeys] [Proposals]" >
Hoping for help.
Thanks and greetings
Arif Khadas
If the primary key values from DB sequence, you can follow this approach:
Using the sequence of database in ADF - Souza Waslley Blog
Oracle Fusion Middleware Technologies: ADF 11 G: generate the primary key sequence number
Otherwise, instead of DB trigger, create the DB function that retrieves the value of the PK and call stored function in the overloaded method create() entity:
-
After insert trigger mutation of error, what is the way to overcome it.
I have two tables namely profiles_answers and user_profileanswers. Based on the requirement that is: when a user inserts the answer in the table of user_profileanswers I need to calculate the weight-age of this issue with the many options available in the profiles_answers table and update this table user_profileanswers age-weight. So, for that, I wrote the following after trigger insert. But when I try to insert it throws me error mutation. As I update the table, used to insert action in the trigger. Please let me how can know I solve this problem.
create or replace
AI_weightageCaluculation TRIGGER AFTER
FOR EACH row INSERT on user_profileanswers
BEGIN
DECLARE
v_a VARCHAR2 (50);
YaeUb VARCHAR2 (50);
V_c VARCHAR2 (50);
v_d VARCHAR2 (50);
ve VARCHAR2 (50);
a_weightage NUMBER;
b_weightage NUMBER;
c_weightage NUMBER;
d_weightage NUMBER;
e_weightage NUMBER;
BEGIN
SELECT option_a, option_b, option_c, option_d, option_e IN
v_a, YaeUb, v_c, v_d, profiles_answers FROM ve
WHERE profile_questions_id =: new.profilequestion_id;
IF (v_a IS NOT NULL AND YaeUb IS NOT NULL AND v_c IS NOT NULL AND v_d IS NOT NULL AND EV IS NOT NULL) THEN
BEGIN
a_weightage: = 85;
b_weightage: = 60;
c_weightage: = 45;
d_weightage: = 30;
e_weightage: = 15;
END;
ELSIF (v_a IS NOT NULL AND YaeUb IS NOT NULL AND v_c IS NOT NULL AND v_d IS NOT NULL AND ve IS NULL) THEN
BEGIN
a_weightage: = 85;
b_weightage: = 60;
c_weightage: = 30;
d_weightage: = 15;
END;
ELSIF (v_a IS NOT NULL AND YaeUb IS NOT NULL AND v_c IS NOT NULL AND v_d IS NULL AND ve IS NULL) THEN
BEGIN
a_weightage: = 85;
b_weightage: = 45;
c_weightage: = 15;
END;
ON THE OTHER
BEGIN
a_weightage: = 85;
b_weightage: = 15;
END;
END IF;
IF: new.answer = 'A' THEN
BEGIN
UPDATE user_profileanswers
SET weightage = a_weightage
WHERE user_id =: new.user_id
AND profileanswer_id =: new.profileanswer_id
AND profilequestion_id =: new.profilequestion_id;
END;
ELSIF: new.answer = 'B' THEN
BEGIN
UPDATE user_profileanswers
SET weightage = b_weightage
WHERE user_id =: new.user_id
AND profileanswer_id =: new.profileanswer_id
AND profilequestion_id =: new.profilequestion_id;
END;
ELSIF: new.answer = 'C' THEN
BEGIN
UPDATE user_profileanswers
SET weightage = c_weightage
WHERE user_id =: new.user_id
AND profileanswer_id =: new.profileanswer_id
AND profilequestion_id =: new.profilequestion_id;
END;
ELSIF: new.answer = ' THEN
BEGIN
UPDATE user_profileanswers
SET weightage = d_weightage
WHERE user_id =: new.user_id
AND profileanswer_id =: new.profileanswer_id
AND profilequestion_id =: new.profilequestion_id;
END;
ON THE OTHER
BEGIN
UPDATE user_profileanswers
SET weightage = e_weightage
WHERE user_id =: new.user_id
AND profileanswer_id =: new.profileanswer_id
AND profilequestion_id =: new.profilequestion_id;
END;
END IF;
END;
END;
Thanks in advance.
Hmm... Why do after insertion?
CREATE OR REPLACE TRIGGER BI_weightageCaluculation
FRONT INSERT ON user_profileanswers FOR EACH ROW
BEGIN
SELECT BOX: NEW. RESPONSE
WHEN 'A' a_weight THEN
WHEN 'B' THEN b_weight
WHEN 'C' THEN c_weight
When ' THEN d_weight
Of OTHER e_weight
END
in: new.weightage
(SELECT 85 a_weight
Case option_result
WHEN 31 THEN 60
WHEN 15 THEN 60
WHEN 7 THEN 45
another 15
end b_weight
Case option_result
WHEN 31 THEN 45
WHEN 15, THEN 30
When 7 then 15
END c_weight
Case option_result
WHEN 31 THEN 30
When 15 then 15
END d_weight
Case option_result
WHEN 31 THEN 15
END e_weight
FROM (SELECT DECODE (option_a, NULL, 0, 1) +)
Decode (option_b, NULL, 0, 2) +.
Decode (option_c, NULL, 0, 4) +.
Decode (option_d, NULL, 0, 8) +.
Decode(option_e,,0,16) option_result
OF profiles_answers
WHERE profile_questions_id =: new.profilequestion_id));
END;
/
HTH
-
Update/Insert Trigger help
Hello
I have 3 tables and his descriptions are as follows
tab1 (tno1 number, tname1 varchar2 (10));
tab2 (tno2 number, tname2 varchar2 (10), value_type varchar2 (10), transaction_type varchar2 (10), date of transaction_date);
tab 3 (tno3 number, tname3 varchar2 (10));
I want to insert values in tab1 tab2 gets updated based on research
Suppose if I stated
setting a day of tab1 set tname1 = 'ABC' where tno1 = 1234;
Then the values of tab1 and tab 3 should save in tab2. Example of
(1) setting a day tab1 set tname1 = 'ABC' where tno1 = 1234;
(2) select * from tab2.
tno2 tname2 transaction_type transaction_date value_type
1234 XXX OLD UPDATE 30-SEP-2013
1234 YYY NEW UPDATE 30-SEP-2013
Second row showing tname2 YYY that belongs to tab3 (tname3)
TNO1, tno2 and tno3 is common for table tab1 and tab2, tab3 respectively.
How can I do that please help me...
Thanks in advance...
I'm going to ignore previous comments because they don't make sense.
How are you with values you "go running" when it is a trigger? You pass values in the procedures and functions, but not of triggers.
Based on your original description, it seems to work for me...
SQL > create table tab1 (tno1 number, tname1 varchar2 (10))
2.Table created.
SQL > create table tab2 (tno2 COMP, tname2 varchar2 (10), value_type varchar2 (10), transaction_type varchar2 (10), transaction_date date)
2.Table created.
SQL > create table tab 3 (tno3 number, tname3 varchar2 (10))
2.Table created.
SQL > insert into tab 3 values (1234, "YYY")
2.1 line of creation.
SQL > create or replace trigger trg_update_tname
2 after insert or update tname1 on tab1
3 for each line
4 start
5 If the update then
6 insert into tab2 values (: new.tno1,: new.tname1, 'OLD', 'UPDATE', sysdate);
7. Insert tab2
8 select: new.tno1, tname3, 'NEW', 'UPDATE', sysdate
9 in tab 3
10 where tno3 =: new.tno1;
11 end if;
12 If insertion then
13 insert in tab2
14 select: new.tno1, tname3, 'NEW', 'UPDATE', sysdate
15 of tab 3
where the 16 tno3 =: new.tno1;
17 end if;
18 end;
19.Trigger created.
SQL > insert into tab1 values (1234, "XXX")
2.1 line of creation.
SQL > select * from tab2
2.TNO2 TNAME2 REPLACEMENT TRANSACTION_DATE VALUE_TYPE
---------- ---------- ---------- ---------- --------------------
1234 YYY NEW UPDATE OCTOBER 1, 2013 07:55:07SQL > update of tab1 set tname1 = 'ABC' where tno1 = 1234
2.1 line update.
SQL > select * from tab2
2.TNO2 TNAME2 REPLACEMENT TRANSACTION_DATE VALUE_TYPE
---------- ---------- ---------- ---------- --------------------
1234 YYY NEW UPDATE OCTOBER 1, 2013 07:55:07
ABC UPDATE FORMER 1234 OCTOBER 1, 2013 07:55:07
1234 YYY NEW UPDATE OCTOBER 1, 2013 07:55:07If is not what you want then you will need to explain in more detail.
-
Using forms apex instead of insert trigger on view
Hello
I have a requirement where I have to have a form on two table and insert data in which the 1 table a PK that Fk one table.
And I need to get the PK at apex so that I can browse additional after the insert/update successful.
I tried methods.
(1) used two table views to insert and then created instead of trigger to insert it.
questions - work very well until I tried to use his return to apex app because return is not trigger INSTEAD of manage.
(2) created a procedure to insert and then return PK at apex.
Form questions - about the procedure does not allow to CHANGE.
looking for expertise on this so that I can make insertion/update two different tables (in view) and get the value of the PK returned to the top.
4.1.1 11 GR 2 linux oc4j
Thanks 4 your time.
#prayforoklahoma
Edited by: Hunk09 May 21, 2013 17:47Hunk09,
1. create a form on the view
2. create a process manual plsql for condition: request = 'CREATE' using your function and save the PK of return in your article
3. for condition: application (SAVE, DELETE') by default, use the process of automatic lineJens
-
Insertion trigger after (does not work)
SQL> DESC MN_MDV_DET Name Null? Type ----------------------------------------- -------- ---------------------------- MDV_NO VARCHAR2(10) MDV_DATE DATE ITEM_NO VARCHAR2(10) ITEM_DESCP VARCHAR2(100) UOM VARCHAR2(10) ITEM_QTY NUMBER(6) BAL_QTY NUMBER(6) REMARKS VARCHAR2(30) ITEM_STAT NUMBER(1) GVN_QTY NUMBER(6) MRF_NO VARCHAR2(10) MRF_DATE DATE SQL> DESC MN_ITEM_PNDNG_ISU Name Null? Type ----------------------------------------- -------- ---------------------------- MRF_NO VARCHAR2(10) MRF_DATE DATE MDV_NO VARCHAR2(10) MDV_DATE DATE ITEM_NO VARCHAR2(10) ITEM_DESCP VARCHAR2(100) UOM VARCHAR2(10) REQ_QTY NUMBER(6) GVN_QTY NUMBER(6) BAL_QTY NUMBER(6) PNDNG_DATE DATE REMARKS VARCHAR2(60)
I'm writing the code block block of details and waiting for inserting record on MN_ITEM_PNDNG_ISU belowSQL> SELECT MDV_NO,MDV_DATE,ITEM_NO FROM MN_MDV_DET WHERE ITEM_STAT=0; MDV_NO MDV_DATE ITEM_NO ---------- --------- ---------- DV-1001 28-JUL-12 1010143 SQL> SELECT MDV_NO,MDV_DATE,ITEM_NO FROM MN_MDV_DET WHERE ITEM_STAT=1; MDV_NO MDV_DATE ITEM_NO ---------- --------- ---------- DV-1001 28-JUL-12 1010138 DV-1001 28-JUL-12 1010100
but when I put the condition WHERE it was not inserting record in MN_ITEM_PNDNG_ISU and when I remove the WHERE Condition it works smoothly. something wrong in my trigger for insertion after?
I want to insert records on MN_ITEM_PNDNG_ISU where ITEM_STAT = 0 or NULL only. as above query run in SQL Prompt.
ConcerningINSERT INTO MN_ITEM_PNDNG_ISU (MRF_NO , MRF_DATE , MDV_NO , MDV_DATE , ITEM_NO , ITEM_DESCP , UOM , REQ_QTY , GVN_QTY , BAL_QTY , PNDNG_DATE , REMARKS ) SELECT :MN_MDV_DET.MRF_NO, :MN_MDV_DET.MRF_DATE, :MN_MDV_DET.MDV_NO, :MN_MDV_DET.MDV_DATE, :MN_MDV_DET.ITEM_NO, :MN_MDV_DET.ITEM_DESCP, :MN_MDV_DET.UOM, :MN_MDV_DET.ITEM_QTY, :MN_MDV_DET.GVN_QTY, :MN_MDV_DET.BAL_QTY, SYSDATE, :MN_MDV_DET.REMARKS FROM MN_MDV_DET WHERE :MN_MDV_DET.ITEM_QTY=0;
Hello
Try:
If nvl(:MN_MDV_DET.) ITEM_STAT, 0) = 0 then
INSERT INTO MN_ITEM_PNDNG_ISU
(MRF_NO,
MRF_DATE,
MDV_NO,
MDV_DATE,
ITEM_NO,
ITEM_DESCP,
UNIT OF MEASURE,
REQ_QTY,
GVN_QTY,
BAL_QTY,
PNDNG_DATE,
REMARKS)
Values)
: MN_MDV_DET. MRF_NO,
: MN_MDV_DET. MRF_DATE,
: MN_MDV_DET. MDV_NO,
: MN_MDV_DET. MDV_DATE,
: MN_MDV_DET. ITEM_NO,
: MN_MDV_DET. ITEM_DESCP,
: MN_MDV_DET. UNIT OF MEASURE,
: MN_MDV_DET. ITEM_QTY,
: MN_MDV_DET. GVN_QTY,
: MN_MDV_DET. BAL_QTY,
SYSDATE,
: MN_MDV_DET. REMARKS);end if;
-
Hello Experts...
I'm trying to insert the value from table to another table using an insert in the after trigger
I have two tables:
RATE_TABLE: (rate_id, rate_value_user_id)
rate_avg_table: (user_id, avg_rate)
the trigger will insert the average value for each user id
the point is I want the trigger to clear all data from the rate_avg_able every time insert before the new values
so I created this trigger and it compiled successfully :)
create or replace trigger "RATING_AI".
AFTER
INSERT or update or delete on 'RATING_TABLE '.
for each line
Start
delete from rate_avg where 1 = 1;
insert into rate_avg (user_id, rate_avg)
Select user_id, AVG (rate_value)
rating
Group by user_id;
end;
the problem is when im trying to insert the new value in the rate_table
It gives me an error message that the table is changing:
ORA-04091: table RATING is changing, the trigger/function cannot see ORA-06512: at "RATING_AI", line 5 ORA-04088: error during execution of trigger 'RATING_AI '.
any ideas?
Edited by: 933151 10 may 2012 16:01If you really want to do it this way, you don't want or need a level of the trigger line, you want a statement-level trigger. This fires the statement once, not once for each row that is changed by.
create or replace trigger "RATING_AI" AFTER insert or update or delete on "RATING_TABLE" begin delete from rate_avg; insert into rate_avg (user_id, rate_avg) select user_id, AVG(rate_value) from rating_table Group by user_id; end;
That being said, however, it seems quite inefficient to recalculate the data every time. This type of computed value storage also violates standards. If there is enough of a few lines in RATING_TABLE that there is no performance problem recalculation of the average for each USER_ID whenever a row is changed, there is probably no need to store the average at all - you just might he calculate the runtime (possibly through a view). If you really need store the calculated value, because it is too expensive to calculate it at run time, you wouldn't want to certainly to her recalculate whenever the data in the underlying table has changed. Instead, you do not want to recalculate the data only for the USER_ID values in RATING_TABLE that had some kind of change. You probably want to use a materialized view that refreshes on commit for this sort of thing, so that you don't have to write code to keep summary data in sync with the detail data.
Justin
-
I am trying to write a trigger that will update a neck date after each insertion.
CREATE OR REPLACE TRIGGER PS1. XX_CDATE
AFTER INSERT ON ps1.COMMNPLANBUDGET
Old SEO AS OLD AS new NEW
FOR EACH LINE
declare the PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
Update ps1.COMMNPLANBUDGET set CREATION_DATE = sysdate where PROJECTID =: new. PROJECTID;
commit;
END XX_CDATE;
For the same thing, I wrote the code above, it created successfully but when I am inserting a record pass date is not updated. Please let me know where I did wrong. Thanks in advanceIt's everything you want
create or replace trigger ps1.xx_cdate before insert on ps1.commnplanbudget referencing old as old new as new for each row begin :new.creation_date := sysdate; end xx_cdate;
Use a trigger to insert BEFORE and just change the: NEW value
-
After the insert trigger error
Hello
I created a trigger after insert according to for me, it's OK, but it show me error can not insert Null in code.
CREATE OR REPLACE TRIGGER "AFT_INS_CRM_CUSTOMER_CONTACTS" AFTER INSERT ON FH_TAPROD.CRM_SALES_CUSTOMER_CONTACTS FOR EACH ROW DECLARE custo_id NUMBER; var_code varchar2(8); cont_code varchar2(5); BEGIN SELECT CUSTOMER_ID INTO custo_id FROM CRM_SALES_CUSTOMER_CONTACTS WHERE ID =:NEW.ID; select CODE into var_code from VENDOR_CUSTOMER_MAS where CRM_CUST_ID=custo_id ; SELECT LPAD ( NVL(MAX(CONTACT_CODE), 0)+ 1, 5, '0') into cont_code FROM vendor_customer_contact insert into VENDOR_CUSTOMER_CONTACT(SBU_CODE ,CODE,CONTACT_CODE, CONTACT_NAME ,PHONE_NO1 ,MOBILE_NO ,EMAIL, ADDRESS1,CUST_ID,UPLOAD_CRM) values('0002',var_code,cont_code,:NEW.CONTACT_NAME,:NEW.CONTACT_PHONE,:NEW.CONTACT_CELL,:NEW.CONTACT_EMAIL,:NEW.CONTACT_ADDRESS,custo_id,'CRM'); END;
CREATE TABLE "CRM_SALES_CUSTOMER_CONTACTS" ( "ID" NUMBER, "CUSTOMER_ID" NUMBER, "CONTACT_NAME" VARCHAR2(255), "CONTACT_EMAIL" VARCHAR2(255), "CONTACT_PHONE" VARCHAR2(255), "CONTACT_CELL" VARCHAR2(255), "CONTACT_ADDRESS" VARCHAR2(4000), PRIMARY KEY ("ID") ENABLE ) / INSERT INTO CRM_SALES_CUSTOMER_CONTACTS VALUES (204414862717175278810736770347803084847, 204232590877603599356756434170666837075, 'SANJAY', '[email protected]', 1246456, 57152357,'Near Post Office');
My after insert a tableCREATE OR REPLACE TRIGGER "BIU_CRM_SALES_CUST_CONTACTS" BEFORE INSERT OR UPDATE ON CRM_SALES_CUSTOMER_CONTACTS FOR EACH ROW begin if inserting and :new.id is null then select to_number(sys_guid(),'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX') into :new.id from dual; end if; if inserting then :new.created_by := nvl(v('APP_USER'),USER); :new.created_on := sysdate; end if; if updating then :new.updated_by := nvl(v('APP_USER'),USER); :new.updated_on := sysdate; end if; end;
CREATE TABLE "VENDOR_CUSTOMER_CONTACT" ( "SBU_CODE" VARCHAR2(4) NOT NULL ENABLE, "CODE" VARCHAR2(8) NOT NULL ENABLE, "CONTACT_CODE" VARCHAR2(5) NOT NULL ENABLE, "CONTACT_NAME" VARCHAR2(1000) NOT NULL ENABLE, "PHONE_NO1" VARCHAR2(100), "MOBILE_NO" VARCHAR2(25), "EMAIL" VARCHAR2(1000), "ADDRESS1" VARCHAR2(4000), "CUST_ID" NUMBER, "UPLOAD_CRM" VARCHAR2(10), CONSTRAINT "VCV_PK" PRIMARY KEY ("SBU_CODE", "CODE", "CONTACT_CODE") ENABLE )
How to solve it.ORA-01400: cannot insert NULL into ("FH_TAPROD"."VENDOR_CUSTOMER_CONTACT"."CODE") ORA-06512: at "FH_TAPROD.AFT_INS_CRM_CUSTOMER_CONTACTS", line 30 ORA-04088: error during execution of trigger 'FH_TAPROD.AFT_INS_CRM_CUSTOMER_CONTACTS'
Thank you
Published by: 805629 on January 14, 2011 01:26This is the error...
SELECT CUSTOMER_ID INTO custo_id FROM CRM_SALES_CUSTOMER_CONTACTS WHERE ID =: NEW.ID;
Is there a reason why not to use: NEW. CUSTOMER_ID rather the query?
Maybe you are looking for
-
Satellite A300 keys menu does not display drop-down
Hey guys,. I think that when I delete a whole bunch of programs, I have deleted something that I wouldn't by chance. When I press on and press and hold the Fn key and press one of the function keys (F1 to F12), the computer no longer displays the dro
-
Regarding the 8 Developer Preview window
Hello Sir, It came I used window Developer 8 in my laptop but its why not active. my friend has also install overview Developer window 8 in our laptop and his show of activated window but not activated why. can you tell me how to activate the window
-
Problem with PCI-GPIB card control Agilent 8648 D generator interface
Hello I downloaded the driver Plug-and-Play (project-style) for Agilent 8648 A generator of signals. I use LabVIEW 2011. I open the file project and resource VISA name menu, select COM1. Note that I use 82350B of the PCI-GPIB Interface Card. I run th
-
Keyboard Microsoft Wireless Photo keyboard 1027 Photo wireless
where can I find the driver for a Microsoft Wireless Photo keyboard Microsoft Wireless picture 1027 keyboard?
-
HOW TO READ BACKUP FILES ON MY HARD DRIVE EXTERNALLY USING VISTA HOME OS WINMINPC
I have CARNT SEE MY COMPUTER BACK UP IMAGE ON MY EXTERNAL HARD DRIVE. MY WATCH LAPLINK SOFTWARE THAT IT REGISTERED UNDER WINMINPC. BUT IT WON'T IF POSTER NOT ON THE SEAGATE HARD DRIVE.