Update Table statement in pre-commit trigger
Hi,
I would need to update one table before commit in the form and hence I need to write an update table statement in pre-commit trigger. Can anyone help me with the sample code or how sould i be able to write a Update table statement from form-level trigger. Normal update statement is throwing me errors.
Thanks in adv
I wouldn't recommend the PRE-COMMIT trigger unless it is your requirement to execute the UPDATE statement every time the form commits, whether it is updating or inserting or deleting.
Other wise you can use the PRE-UPDATE, PRE-DELETE and PRE-INSERT triggers; for this case you create a procedure under Program Units node in the Form's navigator that includes your "UPDATE" SQL statement and you call this procedure from the triggers you need to execute it from.
Example:
PROCEDURE UPDATE_MYTABLE IS
BEGIN
UPDATE MYTABLE SET MY_COLUMN1 = MY_VALUE1,
MY_COLUMN2 = MY_VALUE2,
MY_COLUMN3 = MY_VALUE3
WHERE ... condition;
END;
PRE-UPDATE trigger code:
BEGIN
UPDATE_MYTABLE;
END;Try it and let us know if this is your requirement.
Tony
Edited by: Tony Garabedian on Sep 5, 2008 10:29 AM
Similar Messages
-
Creating a better update table statement
Hello,
I have the following update table statement that I would like to make more effecient. This thing is taking forever. A little background. The source table/views are not indexed and the larger of the two only has 150k records. Any ideas on making more effecient would be appreciate.
Thanks.
Ryan
Script:
DECLARE
V_EID_CIV_ID SBI_EID_W_VALID_ANUM_V.SUBJECT_KEY%TYPE;
V_EID_DOE DATE;
V_EID_POE SBI_EID_W_VALID_ANUM_V.POINT_OF_ENTRY%TYPE;
V_EID_APPR_DATE DATE;
V_CASE_CIV_ID SBI_DACS_CASE_RECORDS.CASE_EID_CIV_ID%TYPE;
V_CASE_DOE DATE;
V_CASE_POE SBI_DACS_CASE_RECORDS.CASE_CODE_ENTRY_PLACE%TYPE;
V_CASE_APPR_DATE DATE;
V_CASE_DEPART_DATE DATE;
V_SBI_UPDATE_STEP SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP%TYPE;
V_SBI_CIV_ID SBI_DACS_CASE_RECORDS.SBI_CIV_ID%TYPE;
CURSOR VALID_CIV_ID_FROM_EID IS
SELECT EID.SUBJECT_KEY,
TO_DATE(EID.PROCESS_ENTRY_DATE),
EID.POINT_OF_ENTRY,
TO_DATE(EID.APPREHENSION_DATE),
DACS.CASE_EID_CIV_ID,
TO_DATE(DACS.CASE_DATE_OF_ENTRY,'YYYYMMDD'),
DACS.CASE_CODE_ENTRY_PLACE,
TO_DATE(DACS.CASE_DATE_APPR,'YYYYMMDD'),
TO_DATE(DACS.CASE_DATE_DEPARTED,'YYYYMMDD'),
DACS.SBI_UPDATE_STEP,
DACS.SBI_CIV_ID
FROM SBI_EID_W_VALID_ANUM_V EID,
SBI_DACS_CASE_RECORDS DACS
WHERE DACS.CASE_NBR_A = EID.ALIEN_FILE_NUMBER;
BEGIN
OPEN VALID_CIV_ID_FROM_EID;
SAVEPOINT A;
LOOP
FETCH VALID_CIV_ID_FROM_EID INTO V_EID_CIV_ID, V_EID_DOE, V_EID_POE,V_EID_APPR_DATE,V_CASE_CIV_ID, V_CASE_DOE,V_CASE_POE,V_CASE_APPR_DATE,V_CASE_DEPART_DATE,V_SBI_UPDATE_STEP,V_SBI_CIV_ID;
DBMS_OUTPUT.PUT_LINE('BEFORE');
EXIT WHEN VALID_CIV_ID_FROM_EID%FOUND;
DBMS_OUTPUT.PUT_LINE('AFTER');
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_CASE_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 1
WHERE V_CASE_CIV_ID IS NOT NULL
AND V_CASE_CIV_ID <> 0;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 2
WHERE V_SBI_CIV_ID IS NULL AND V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE
AND V_EID_APPR_DATE = V_CASE_DEPART_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 3
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 4
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4 ;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 5
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE <> V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 6
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 7
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 8
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 9
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 10
WHERE V_SBI_UPDATE_STEP = 0
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
END LOOP;
CLOSE VALID_CIV_ID_FROM_EID;
COMMIT;
END;
-----Thats it. Thanks for your help.
RyanPlease use [ code] or [ pre] tags to format code before posing:
DECLARE
V_EID_CIV_ID SBI_EID_W_VALID_ANUM_V.SUBJECT_KEY%TYPE;
V_EID_DOE DATE;
V_EID_POE SBI_EID_W_VALID_ANUM_V.POINT_OF_ENTRY%TYPE;
V_EID_APPR_DATE DATE;
V_CASE_CIV_ID SBI_DACS_CASE_RECORDS.CASE_EID_CIV_ID%TYPE;
V_CASE_DOE DATE;
V_CASE_POE SBI_DACS_CASE_RECORDS.CASE_CODE_ENTRY_PLACE%TYPE;
V_CASE_APPR_DATE DATE;
V_CASE_DEPART_DATE DATE;
V_SBI_UPDATE_STEP SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP%TYPE;
V_SBI_CIV_ID SBI_DACS_CASE_RECORDS.SBI_CIV_ID%TYPE;
CURSOR VALID_CIV_ID_FROM_EID IS
SELECT EID.SUBJECT_KEY,
TO_DATE(EID.PROCESS_ENTRY_DATE),
EID.POINT_OF_ENTRY,
TO_DATE(EID.APPREHENSION_DATE),
DACS.CASE_EID_CIV_ID,
TO_DATE(DACS.CASE_DATE_OF_ENTRY,'YYYYMMDD'),
DACS.CASE_CODE_ENTRY_PLACE,
TO_DATE(DACS.CASE_DATE_APPR,'YYYYMMDD'),
TO_DATE(DACS.CASE_DATE_DEPARTED,'YYYYMMDD'),
DACS.SBI_UPDATE_STEP,
DACS.SBI_CIV_ID
FROM SBI_EID_W_VALID_ANUM_V EID,
SBI_DACS_CASE_RECORDS DACS
WHERE DACS.CASE_NBR_A = EID.ALIEN_FILE_NUMBER;
BEGIN
OPEN VALID_CIV_ID_FROM_EID;
SAVEPOINT A;
LOOP
FETCH VALID_CIV_ID_FROM_EID INTO V_EID_CIV_ID, V_EID_DOE,
V_EID_POE,V_EID_APPR_DATE,V_CASE_CIV_ID, V_CASE_DOE,
V_CASE_POE,V_CASE_APPR_DATE,V_CASE_DEPART_DATE,V_SBI_UPDATE_STEP,V_SBI_CIV_ID;
DBMS_OUTPUT.PUT_LINE('BEFORE');
EXIT WHEN VALID_CIV_ID_FROM_EID%FOUND;
DBMS_OUTPUT.PUT_LINE('AFTER');
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_CASE_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 1
WHERE V_CASE_CIV_ID IS NOT NULL
AND V_CASE_CIV_ID <> 0;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 2
WHERE V_SBI_CIV_ID IS NULL AND V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE
AND V_EID_APPR_DATE = V_CASE_DEPART_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 3
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 4
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4 ;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 5
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE <> V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 6
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_POE = V_CASE_POE
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 7
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_APPR_DATE = V_CASE_APPR_DATE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 8
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 9
WHERE V_SBI_UPDATE_STEP = 0
AND V_EID_DOE = V_CASE_DOE
AND V_EID_POE = V_CASE_POE;
UPDATE SBI_DACS_CASE_RECORDS
SET SBI_DACS_CASE_RECORDS.SBI_CIV_ID = V_EID_CIV_ID,
SBI_DACS_CASE_RECORDS.SBI_UPDATE_STEP = 10
WHERE V_SBI_UPDATE_STEP = 0
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) > -4
AND (V_EID_APPR_DATE - V_CASE_APPR_DATE) < 4;
END LOOP;
CLOSE VALID_CIV_ID_FROM_EID;
COMMIT;
END;Peter D. -
PRE-COMMIT trigger and duplicate client id
Hello,
I generated client id in pre-commit trigger but data entry complainted that they got message "Id already exists". How to avoid same id used by different data entry?
Thanks.try using an Oracle sequence (nocycle) to generate the id
-
Max no. of Update SQL statements before a commit
In Oracle 10.2 what is maximum number of UPDATE statements that I can execute before issuing commit.
If maximum is there either by no. of SQL statements or size in KB, what will happen if I go above this number.
Thanks in advance for your response.
Edited by: vbforums on Feb 21, 2011 3:50 PMsb92075 wrote:
I executed 5000+ update statements from Java in one shotI am curious.
Does each UPDATE change only a single row?
I'll ask a different way.
Can a single UPDATE statement change all desired rows?yes
SQL> conn scott/tiger
Connected.
SQL> select table_name from user_tables;
TABLE_NAME
EMP
DEPT
SQL> create table mytest(cola varchar2(1));
Table created.
SQL> insert into mytest values ('A');
1 row created.
SQL> insert into mytest values ('A');
1 row created.
SQL> insert into mytest values ('A');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from mytest;
C
A
A
A
SQL> update mytest set cola='B' where cola='A';
3 rows updated.
SQL> commit;
Commit complete.
SQL> select i * from mytest;
C
B
B
B
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@vmlnx01 dbs]$ exit
logout -
Execution of ddl statement in post-insert trigger
hi,
I'm working on headstart 6.5. I wants to execute a DDL statement in post-insert-trigger.The problem is this trigger is executed in between pre-commit and post-forms-commit.In pre-commit the transaction is opened with a insert statement that is inserting "open" in field status which is having a deffered check constraint QMS_NEED_TO_CLOSE_TRANSACTION.In post-forms-commit it will check whether the transaction is open if yes will check the business rule will delete the data that was inserted into qms_transaction in pre-commit trigger and will close the transaction .
In between if i execute a DDl statement a commit will be performed on the insert statement written in pre-commit trigger.This will violate the check-constraint and we will get the error qms_need_to_close_transaction violated.
My business logic wants this statement to be executed at the post-insert trigger on the block.Is this possible??
Does anyone have face the same problem?Whts the workaround for the same?Hello,
You could use the execute_query after the commit_form called, by exeample in a KEY-COMMIT trigger.
KEY-COMMIT trigger
Commit_Form ;
Go_block( 'master_block' ) ;
Execute_Query ;Francois -
Problem: trying to update all detail rows on pre-commit (MASTER DETAIL FORM
Hi:
I got a MASTER DETAIL form... and I need to update every detail row of this form (if the master was updated) before commiting the changes. the problem is that i cannot do that for instance in PRE-COMMIT or ON-COMMIT... it's an "illegal operation". I achieved part of it by coding KEY-COMMIT... but that did not solve the all problem. first take a look of the kind of code i want execute before commiting.
form trigger key-commit code is is somehow like this:
DECLARE
tot_line NUMBER (3);
line NUMBER (3);
begin
IF NAME_IN ('system.form_status') = 'CHANGED'
THEN
GO_BLOCK ('DETAIL');
LAST_RECORD;
tot_line := GET_BLOCK_PROPERTY ('DETAIL', current_record);
FIRST_RECORD;
line:= 1;
LOOP
:detail.quant := :detail.quant + 1;
EXIT WHEN line= tot_line;
next_record;
line:= line+ 1;
END LOOP;
FIRST_RECORD;
GO_BLOCK ('MASTER');
END IF;
COMMIT;
end;
The problem is for instance when the users close form in the "X" button (right top, near minimize form) ... If they do that Forms ask "Do you want to save changes?" ... and with this i do not execute the update of the detail rows...
But there are other situations when this happens... for instance if EXECUTE_QUERY when i change a record...
Anyone help?
Joao OliveiraUse PRE-UPDATE trigger (Master block).
begin
update <detail_table>
set quant + 1
where <detail_table>.<relaition_column1> = :<Master_block>.<relaition_item1>
and <detail_table>.<relaition_columnN> = :<Master_block>.<relaition_itemN>
and <detail_block_WHERE>;
EXCEPTION WHEN OTHERS THEN NULL;
end; -
Database trigger cannot read the updating table
I want to create a database trigger :
after insert or update on EMP
for each row
begin
select sum(EMP.salary) from EMP WHERE .....
end;
However, I got an error is that I cannot read the updating table if the trigger is 'for each row'. Can anyone help me to to this?
More, I must use 'for each row' trigger for this case.
nullI think the SQL statement should be
strSQL = "SELECT * FROM MaterialLotJobJoint WHERE JobID=" & _
tempvars!JobID & " AND MatLotID=" & tempvars!MatLotID
This assumes thatJobID and MatLotID are number fields.
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
Update table using merge or Update statement
Hi All,
We have oracle 10G R2 On windows...
We have tables BROK_DEALER_MAP and DTRMIS_REPORT.
create table BROK_DEALER_MAP
SL_NO NUMBER,
BROK_DLR_CODE VARCHAR2(30),
EMP_TAG VARCHAR2(30),
REMARKS VARCHAR2(60),
CONS_CODE VARCHAR2(30),
BROK_DLR_NAME VARCHAR2(50),
BROKER_TYPE VARCHAR2(30),
BROK_DLR_0 VARCHAR2(30),
CATG_DESC VARCHAR2(60),
Category VARCHAR2(30));
desc DTRMIS_REPORT
SL_NO
POSTED_DATE
ZONE
AMC_REGION
CITY
BROK_DLR_CODE
BROK_DLR_NAME
SUB_BROKER
B_TYPE
FOLIO_NO
INVESTOR_NAME
TAX_NO
INV_TAG
SCHEME_CODE
SCHEME_NAME
SCH_CLASS
TRXN_MODE
CHN_TAG
FP_COUNT
FP_AMOUNT
AP_COUNT
AP_AMOUNT
PUR_COUNT
PUR_AMOUNT
SIP_COUNT
SIP_AMOUNT
SI_COUNT
SI_AMOUNT
RED_COUNT
RED_AMOUNT
SO_COUNT
SO_AMOUNT
DR_COUNT
DR_AMOUNT
STP_COUNT
STP_AMOUNT
NET_SALES
DISTRIBUTOR_TYPE
SCHEME_TYPE
FOCUS_PRODUCT
RM_CODE
RM_NAMEtable BROK_DEALER_MAP doesn't have any duplicate records.
table DTRMIS_REPORT have more than 2 lacks duplicate records.
Now i want to update table DTRMIS_REPORT (DISTRIBUTOR_TYPY COLUMN) With the values of BROK_DEALER_MAP (CATEGORY COLUMN).
For that i have written merge statement like below
merge into dtrmis_report a
using brok_dealer_map b
on (a.brok_dlr_code=b.cons_code)
when matched then
update set a.Distributor_type=b.category
where a.brok_dlr_code=b.cons_code;IT's giving error saying ORA-30926: unable to get a stable set of rows in the source tables.
How to update the table.
Please help.Chanchal Wankhade wrote:
IT's giving error saying ORA-30926: unable to get a stable set of rows in the source tables.That means there are duplicate records in your source table.
Please post the output of the below
select cons_code
from brok_dealer_map
group by cons_code
having count(*) > 1;In case of duplicate CONS_CODE, you need to decide with which the target table should get updated
And are you seriously giving a where condition in merge like you posted..?
Edited by: jeneesh on Dec 19, 2012 9:56 AM -
COMMIT statement generates error in trigger
My COMMIT statement generates error from my 'when-button-pressed' trigger.
First I issue a very simple Insert statement, then a commit, but I get:
FRM-41009. Function key not allowed. Press Ctrl+F1 for list of valid keys.
Do you think I have a trigger somewhere else that could be affecting this commit ?
BobI FIGURED IT OUT, FOLKS.
I was in query mode before issuing the commit. I simply chose a record and it worked.
Thanks anyway,
bob -
Pre-insert-trigger ignoring assignments
Hi,
I have this code in a PRE-INSERT-TRIGGER of a database table block:
Select emp_seq.Nextval Into :EMP.EMPNO From dual;
Select Sysdate Into :EMP.LASTCHANGED From dual;
And i have this code in a PRE-UPDATE-TRIGGER of the same block:
Select Sysdate Into :EMP.LASTCHANGED From dual;
given scenario:
1) query records from the table into a block:
empno ename lastchanged
1 Smith 01.12.2008
2 Johnson 01.12.2008
2) change empname in any record except no. 1:
empno ename lastchanged
1 Smith 01.12.2008
2 Johannson 01.12.2008
3) create a new record somewhere above the changed record
empno ename lastchanged
1 Smith 01.12.2008
<null> <null> <null>
2 Johannson 01.12.2008
4) insert ename in new record
empno empname lastchanged
1 Smith 01.12.2008
<null> Obama <null>
2 Johannson 01.12.2008
5) do_key('commit_form')
with Forms 6.0.8.23.2 -> working fine
with Forms 6.0.8.27.0 -> ORA-01400:: cannot insert NULL into ("EMP"."EMPNO")
Any assignment in the pre-insert-trigger is ignored! Can anyone help me with this bug? Thanks in advancemessage(:EMP.EMPNO) is always Null ...
Everything works if there's no update of a record with higher record-number in the transaction. But the scenario in post 1 doesnt work with Forms 6.0.8.27.0Ugh -- that's ugly!
Unfortunately, opening a Service Request with Oracle will get you nowhere, since Oracle no longer supports Forms 6i.
Yesterday, I experienced something very similar with the same version of Forms, specifically this part: Everything works if there's no update of a record with higher record-number in the transaction.*
If I updated a higher record number in the block, I could NOT get Forms to subsequently store a value in a column in a prior record. I would set the value in the column, and immediately display the value, and it was null! Fortunately in my case, the stored value was only to enable skipping a database lookup in a subsequent pass, so I just skipped working on a solution.
However, in your case, the problem is a show-stopper.
What I found was that if I navigated back to the first record in the block, the problem went away. So maybe try this in your commit process:
Go_block('ABC');
First_Record;
Synchronize;
Commit_Form;Let us know if that works for you. -
TDE Issue with UPDATE/SELECT statement
We just implemented TDE on a table and now our import script is getting errors. The import script has not changed and has been running fine for over a year. The script failed right after applying TDE on the table.
Oracle 10g Release 2 on Solaris.
Here are the encrypted colums:
COLUMN_NAME ENCRYPTION_ALG SALT
PERSON_ID AES 192 bits key NO
PERSON_KEY AES 192 bits key NO
USERNAME AES 192 bits key NO
FIRST_NAME AES 192 bits key NO
MIDDLE_NAME AES 192 bits key NO
LAST_NAME AES 192 bits key NO
NICKNAME AES 192 bits key NO
EMAIL_ADDRESS AES 192 bits key NO
AKO_EMAIL AES 192 bits key NO
CREATION_DATE AES 192 bits key NO
Here is the UPDATE/SELECT statement that is failing:
UPDATE cslmo_framework.users a
SET ( person_id
, username
, first_name
, middle_name
, last_name
, suffix
, user_status_seq
= (
SELECT person_id
, username
, first_name
, middle_name
, last_name
, suffix
, user_status_seq
FROM cslmo.vw_import_employee i
WHERE i.person_key = a.person_key
WHERE EXISTS
SELECT 1
FROM cslmo.vw_import_employee i
WHERE i.person_key = a.person_key
AND ( NVL(a.person_id,0) <> NVL(i.person_id,0)
OR NVL(a.username,' ') <> NVL(i.username,' ')
OR NVL(a.first_name,' ') <> NVL(i.first_name,' ')
OR NVL(a.middle_name,' ') <> NVL(i.middle_name,' ')
OR NVL(a.last_name,' ') <> NVL(i.last_name,' ')
OR NVL(a.suffix,' ') <> NVL(i.suffix,' ')
OR NVL(a.user_status_seq,99) <> NVL(i.user_status_seq,99)
cslmo@awpswebj-dev> exec cslmo.pkg_acpers_import.p_users
Error importing USERS table.START p_users UPDATE
Error Message: ORA-01483: invalid length for DATE or NUMBER bind variableI rewrote the procedure using BULK COLLECT and a FORALL statement and that seems to work fine. Here is the new code:
declare
bulk_errors EXCEPTION ;
PRAGMA EXCEPTION_INIT(bulk_errors,-24381) ;
l_idx NUMBER ;
l_err_msg VARCHAR2(2000) ;
l_err_code NUMBER ;
l_update NUMBER := 0 ;
l_count NUMBER := 0 ;
TYPE person_key_tt
IS
TABLE OF cslmo_framework.users.person_key%TYPE
INDEX BY BINARY_INTEGER ;
arr_person_key person_key_tt ;
TYPE person_id_tt
IS
TABLE OF cslmo_framework.users.person_id%TYPE
INDEX BY BINARY_INTEGER ;
arr_person_id person_id_tt ;
TYPE username_tt
IS
TABLE OF cslmo_framework.users.username%TYPE
INDEX BY BINARY_INTEGER ;
arr_username username_tt ;
TYPE first_name_tt
IS
TABLE OF cslmo_framework.users.first_name%TYPE
INDEX BY BINARY_INTEGER ;
arr_first_name first_name_tt ;
TYPE middle_name_tt
IS
TABLE OF cslmo_framework.users.middle_name%TYPE
INDEX BY BINARY_INTEGER ;
arr_middle_name middle_name_tt ;
TYPE last_name_tt
IS
TABLE OF cslmo_framework.users.last_name%TYPE
INDEX BY BINARY_INTEGER ;
arr_last_name last_name_tt ;
TYPE suffix_tt
IS
TABLE OF cslmo_framework.users.suffix%TYPE
INDEX BY BINARY_INTEGER ;
arr_suffix suffix_tt ;
TYPE user_status_seq_tt
IS
TABLE OF cslmo_framework.users.user_status_seq%TYPE
INDEX BY BINARY_INTEGER ;
arr_user_status_seq user_status_seq_tt ;
CURSOR users_upd IS
SELECT i.person_key
,i.person_id
,i.username
,i.first_name
,i.middle_name
,i.last_name
,i.suffix
,i.user_status_seq
FROM cslmo.vw_import_employee i ,
cslmo_framework.users u
WHERE i.person_key = u.person_key ;
begin
OPEN users_upd ;
LOOP
FETCH users_upd
BULK
COLLECT
INTO arr_person_key
, arr_person_id
, arr_username
, arr_first_name
, arr_middle_name
, arr_last_name
, arr_suffix
, arr_user_status_seq
LIMIT 100 ;
FORALL idx IN 1 .. arr_person_key.COUNT
SAVE EXCEPTIONS
UPDATE cslmo_framework.users u
SET
person_id = arr_person_id(idx)
, username = arr_username(idx)
, first_name = arr_first_name(idx)
, middle_name = arr_middle_name(idx)
, last_name = arr_last_name(idx)
, suffix = arr_suffix(idx)
, user_status_seq = arr_user_status_seq(idx)
WHERE u.person_key = arr_person_key(idx)
AND
( NVL(u.person_id,0) != NVL(arr_person_id(idx),0)
OR
NVL(u.username,' ') != NVL(arr_username(idx),' ')
OR
NVL(u.first_name,' ') != NVL(arr_first_name(idx),' ')
OR
NVL(u.middle_name, ' ') != NVL(arr_middle_name(idx), ' ')
OR
NVL(u.last_name,' ') != NVL(arr_last_name(idx),' ')
OR
NVL(u.suffix,' ') != NVL(arr_suffix(idx),' ')
OR
NVL(u.user_status_seq,99) != NVL(arr_user_status_seq(idx),99)
l_count := arr_person_key.COUNT ;
l_update := l_update + l_count ;
EXIT WHEN users_upd%NOTFOUND ;
END LOOP ;
CLOSE users_upd ;
COMMIT ;
dbms_output.put_line('updated records: ' || l_update);
EXCEPTION
WHEN bulk_errors THEN
FOR i IN 1 .. sql%BULK_EXCEPTIONS.COUNT
LOOP
l_err_code := sql%BULK_EXCEPTIONS(i).error_code ;
l_err_msg := sqlerrm(-l_err_code) ;
l_idx := sql%BULK_EXCEPTIONS(i).error_index;
dbms_output.put_line('error code: ' || l_err_code);
dbms_output.put_line('error msg: ' || l_err_msg);
dbms_output.put_line('at index: ' || l_idx);
END LOOP ;
ROLLBACK;
RAISE;
end ;
cslmo@awpswebj-dev> @cslmo_users_update
updated records: 1274There are about 20 or so other procedure in the import script. I don't want to rewrite them.
Does anyone know why the UPDATE/SELECT is failing? I checked Metalink and could not find anything about this problem.This is now an Oracle bug, #9182070 on Metalink.
TDE (transparent data encryption) does not work when an update/select statement references a remote database. -
How to get around ora-ORA-04091: table SSBOSS.SSTRMAST is mutating, trigger
hi,
Does anyone know how one would get around this problem please ?
Here is my dbase trig:
CREATE OR REPLACE TRIGGER SSBOSS.new_not_greater_than_net
BEFORE INSERT OR UPDATE OF newrent ON SSBOSS.SSTRMAST
REFERENCING NEW AS new OLD AS old
FOR each row
DECLARE
not_permitted EXCEPTION;
vnum number := ssboss.nik_f;
BEGIN
IF :new.NEWRENT > vnum then
--AND :old.DELETED = 'N' THEN
RAISE not_permitted;
END IF;
EXCEPTION
WHEN not_permitted THEN
RAISE_APPLICATION_ERROR
(-20001, 'NEWRENT:'||:new.newrent||' '||'OLDRENT:'||' '||:old.netrent||'Action not permitted. Contribution (sstrmast.newrent) value '
||:new.NEWRENT
||' exceeds GROSS rental value (sstrmast.netrent) ');
END;
Here is my problem:
SQL> update sstrmast set newrent = 11;
update sstrmast set newrent = 11
ERROR at line 1:
ORA-04091: table SSBOSS.SSTRMAST is mutating, trigger/function may not see it
ORA-06512: at "SSBOSS.NIK_F", line 4
ORA-06512: at "SSBOSS.NEW_NOT_GREATER_THAN_NET", line 4
ORA-04088: error during execution of trigger 'SSBOSS.NEW_NOT_GREATER_THAN_NET'
I understand why but not how to correct?
Thanks,
nikolia.Hello,
This problem as you might be knowing occurs when you try to select the data from the same table on which the trigger is written. Also this problem is only with the row level trigger and not with the statement level trigger. However the limitation of the statement level trigger is it can not refer to :NEW or :OLD. So now the solution is to capture the value of :NEW or :OLD in the row level trigger (no select statement here) and store it in some global variable. And how do you get the global variable? Using package specification ! a variable declared in a package specification is global in nature. Then use the value so stored in the statement level trigger in the select statement. It will work. Other solution is to use pragma autonomous transaction. Try and let us know. All the best.
Regards -
Need a Query to update table from another table.
I have two tables Table A and Table B , till now in table “A”. I have a column which consist of IDs and duplicate IDs( which are basically formed by Original Ids) , I have another table i.e. table “B” , which gives a mapping between original ids and duplicate Ids
TABLE A:
ID/DUPLICATEID NAME
1 Rahul
1_CAD Pawan
2 Nikhil
3 TOM
3_CAD Ravi
3_MQ Puneet
TABLE B:
ORIGINALID DUPLICATEID
1 1_CAD
3 3_CAD
3 3_MQ
Now I want to have another column in Table “A” , which will give me the mapping between the original Id and duplicate Id as shown in updated table “A”.
UPDATED TABLE A:
ID/DUPLICATEID NAME ORIGINAL_ID
1 Rahul
1_CAD Pawan
2 Nikhil
3 TOM
3_CAD Ravi
3_MQ Puneet
Now I want to write a Query in which I can update this column (ORIGINAL_ID) of Table “A”, from the table B(basically want to update mulitple rows using single query), because table B already has this mapping. Can any one help me in this. I am basically a Java guy , so I don’t know much about it. I hope to get a positive response from you people, Thanks in advance!Here you go...
<pre style="font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%">
<code>
SQL> CREATE TABLE A (ID VARCHAR2(10), NAME VARCHAR2(10), NEW_ID VARCHAR2(10));
Table created.
SQL> INSERT INTO A VALUES ('1', 'Rahul', '');
1 row created.
SQL> INSERT INTO A VALUES ('1_CAD', 'Pawan', '');
1 row created.
SQL> INSERT INTO A VALUES ('2', 'Nikhil', '');
1 row created.
SQL> INSERT INTO A VALUES ('3', 'TOM', '');
1 row created.
SQL> INSERT INTO A VALUES ('3_CAD', 'Ravi', '');
1 row created.
SQL> INSERT INTO A VALUES ('3_MQ', 'Puneet', '');
1 row created.
SQL> CREATE TABLE B (ID VARCHAR2(10), NAME VARCHAR2(10));
Table created.
SQL> INSERT INTO B VALUES ('1', '1_CAD');
1 row created.
SQL> INSERT INTO B VALUES ('3', '3_CAD');
1 row created.
SQL> INSERT INTO B VALUES ('3', '3_MQ');
1 row created.
SQL> COMMIT;
Commit complete.
SQL> UPDATE A
2 SET NEW_ID = NVL((SELECT B.ID FROM B WHERE A.ID = B.NAME),A.ID)
3 /
6 rows updated.
SQL> COMMIT;
Commit complete.
SQL> SELECT * FROM A;
ID NAME NEW_ID
1 Rahul 1
1_CAD Pawan 1
2 Nikhil 2
3 TOM 3
3_CAD Ravi 3
3_MQ Puneet 3
6 rows selected.
</code></pre>
Note: While asking question do give us DML/DDL script. It will make peoples life better.
Karthick.
http://www.karthickarp.blogspot.com/ -
Hi,
I am writing a small program to update tavle TVARV. I don't want to use UPDATE TVARV statement,
is there any FM or Transaction I can use?
Thanks.Hi everyone,
Thanks for your reply.
Sorry I didn't make the question clear.
I have an variable 'AUCIO' in table TVARV already, it's used to update the post period parameter
of program RKO7KO8G. I wrote a small program to update the table TVARV.
TABLES: T009B.
DATA: gv_low(3) type c,
GV_PERIV LIKE T009B-PERIV VALUE 'Z1',
GV_PERIOD LIKE T009B-POPER.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = SY-DATUM
I_PERIV = GV_PERIV
IMPORTING
E_BUPER = GV_PERIOD.
select single low into gv_low from tvarv
where name = 'AUCIO' and type = 'P'.
if gv_low ne gv_period.
update tvarv set low = gv_period
where name = 'AUCIO' and type = 'P'.
commit work.
endif.
The thing is, use UPDATE or INSERT, MODIFY statements is considered dangerous, so I'm
look some other ways to update the table, either through FM or transaction. Can anybody
give me suggestion?
Thanks. -
Can insert but cannot update table.
Hi,
I am finding trouble in something that I thought would be very easy. I have writen some code that simply updates some rows in one table (update table set column = value where critery; commit;). This table isn't associated to any Forms block. The code is properly executed except for forms 40401 exception, but I have dealt with it by changing the message level, as it was suggested in this forum.
My problem is that in spite of getting no error the table isn't updated. I find this pretty weird. I thought it might be some problem related with database permissions, but the same command launched on PL/SQL Developer under the same database connection works fine. I have also checked that insert statement over the same table works properly.
Do you have any idea?
Thanks.Hi,
Thank you very much for your replies. I finally managed to solve the issue and I must apologize for having posted this thread. After all, it was quite an easy solution, as I suspected. A data format question. In Spain, decimal numbers are written with comma - ',' and the data I was trying to update always consisted of numbers. These numbers were coming from character variables, and the problem was behind the types conversion. Things worked properly if I wrote UPDATE BUQUES B SET B.B_ESLORATOTAL=TO_NUMBER('12,23'), but they didn't when I used a variable p_Valor where '12,23' value was stored. So was done in my Forms procedure and it seems it was crashing although I didn't get any error.
I finally managed solved the issue by using FORMS_DDL command and building up the update statement in a string. As soon as I checked what I was storing in this string I noticed the mistake.
Again, thank you very much for your time.
Regards,
Fernando
Maybe you are looking for
-
How can i use multiple row subquery in update statement
Hai All I using group function in my update statement.. and i need to update more rows so i need to use multiple row subquery pls tell me how to use multiple row subquery in update statement For example while i am using this like this i got an error
-
How do I download without paying for it again
-
Hi While executing the idoc, i get , status error 26 - "EDI syntax error" Pl. suggest solution for this prob.
-
When I open the organizer in PS 8 a box pops up that says "updating" with a status bar. While that is doing it's thing I get another box that pops up and says "The watch folder service returned and error: Message format, invalid tag ID". I can click
-
Ipod Classic continues playing podcasts after it ends
I recently bought an iPod classic and upgraded from a second generation iPod. On my second generation iPod when ever a podcast ended the iPod would stop and not play any further ones unless I directed it to. On the iPod classic it moves on to the nex