Migration: 04089 'create or replace trigger "GENSS2K5FORKEYRIG" ' error
hi:
I am trying to migration sqlserver 2008 to 10g.
I try to execute the sql "
+create or replace trigger "GENSS2K5FORKEYRIG"+
+BEFORE INSERT ON STAGE_SS2K5_FN_KEYS+
+FOR EACH ROW+
+BEGIN+
+IF :NEW.OBJECT_ID_gen IS NULL THEN+
+:NEW.OBJECT_ID_gen := MD_META.get_next_id;+
+end if;+
+end GENSS2K5FORKEYRIG;+"
as Migrations , then 04089, where I was wrong?
please help me!
Hi 914847 ,
http://psoug.org/oraerror/ORA-04089.htm
do not create triggers on schema objects owned by sys.
Use a different schema for schema objects - create one if necessary.
-Turloch
SQLDeveloper team
Similar Messages
-
hi i want to create trigger . when insert a row on table , it returns new value and old value . I have many tables and columns . i should to use :new.columntitle and :old.columntitle .Columntitle is refere to name of column in table . but sql developer is not accept it and show this error : BAD BIND VARIABLE 'NEW.COLUMNTITLE' .My code is this :
Create or replace TRIGGER hr.departments_before_insert
before insert on HR.departments
for each row
DECLARE
columnid number ;
columnval number ;
columntitle varchar2(4000);
cursor c2 is
select id,tableid from hr.columns where tableid = 1 ;
tablesid number ;
tablenames varchar2(4000);
cursor c1 is
select id , title from hr.tables where id = 1;
BEGIN
open c1;
loop
fetch c1 into tablesid , tablenames;
EXIT WHEN C1%NOTFOUND;
for rec in c2
loop
select substr(title,instr(title,'.',-1,1)+1) into columntitle from hr.columns where id = rec.id ;
dbms_output.put_line(:new.columntitle); -- in this line the eroor occured : error = " bad bind variable 'new.columntitle' "
end loop;
end loop;
close c1;
end;
-- in loop columntitle=deparment _id and department_name ; when i replace columntitle with department _id in :new , code is work ...
thanksYou have no choice but to specifically list the column names.
If you really have "too many columns", that would tend to imply that you have improperly normalized your schema. Perhaps you need to rethink the data model.
If the real problem is that you want to generate similar triggers for a large number of different tables, you could write a PL/SQL block that generates the CREATE TRIGGER statement for each table and use EXECUTE IMMEDIATE to run those statements for each table. Using dynamic SQL like this significantly complicates the complexity of building the trigger. This may be balanced out, though, by the fact that you only have to write it once rather than writing separate triggers for each table.
Justin -
End-user experience during CREATE OR REPLACE TRIGGER
Is CREATE OR REPLACE TRIGGER intended for you to be able to update a trigger in production while users are actively using a that table's data?
Just wondering how it behaves. People currently in the middle of an event will use the old trigger, while new requests will use the new one?
Thanks
ChuckActually, this one kind of surprised me. I tried:
SESSION1 > DESC t
Name Null? Type
ID NUMBER
DESCR VARCHAR2(10)
SESSION1 > CREATE TRIGGER t_bi
2 BEFORE INSERT OR UPDATE ON t
3 FOR EACH ROW
4 BEGIN
5 :new.descr := UPPER(:new.descr);
6* END;
Trigger created.Then, in anothe session I did:
SESSION2 > INSERT INTO t VALUES (1, 'One');
1 row created.Then in the first session:
SESSION1 > CREATE OR REPLACE TRIGGER t_bi
2 BEFORE INSERT OR UPDATE ON t
3 FOR EACH ROW
4 BEGIN
5 :new.descr := LOWER(:new.descr);
6* END;
Trigger created.
Just to prove no commit happened
SESSION1 >SELECT * FROM t;
no rows selectedI was expecting to see
ORA-00054: resource busy and acquire with NOWAIT specified
or something similar. So in session 2 I did:
SESSION2 > COMMIT;
Commit complete.
SESSION2 > SELECT * FROM t;
ID DESCR
1 ONE
SESSION2 > INSERT INTO t VALUES(2, 'Two');
1 row created.
SESSION2 > SELECT * FROM t;
ID DESCR
1 ONE
2 twoSo, the new trigger is working. Now change it again:
SESSION1 > CREATE OR REPLACE TRIGGER t_bi
2 BEFORE INSERT OR UPDATE ON t
3 FOR EACH ROW
4 BEGIN
5 :new.descr := UPPER(:new.descr);
6 END;
7 /
Trigger created.and back to session 2
SESSION2 > INSERT INTO t VALUES (3, 'Three');
1 row created.
SESSION2 > SELECT * FROM t;
ID DESCR
1 ONE
2 two
3 THREESo, it looks like whichever trigger is current at the time of the insertion or updation seems to control what gets in the database.
John -
Error creating job into trigger using DBMS_SCHEDULER.
Hi,
I am trying to create job using dbms_scheduler package. I have one trigger on insert event on one table. I am creating job using following syntax.
CREATE OR REPLACE TRIGGER TRG_BI_JOB_CONFIG BEFORE INSERT ON JOB_CONFIG FOR EACH ROW
DECLARE
BEGIN
DBMS_SCHEDULER.Create_Job(job_name => 'my_job1'
,job_type => 'PLSQL_BLOCK'
,job_action => 'delete_temp'
,start_date => TO_DATE('15-JUL-2003 1:00:00 AM', 'dd-mon-yyyy hh:mi:ss PM')
,repeat_interval => 'FREQ=DAILY'
,enabled => TRUE
,comments => 'DELETE FOR job schedule.');
EXCEPTION
WHEN OTHERS THEN RAISE;
END;
but I am getting following error while inserting into JOB_CONFIG table.
ORA-04092: cannot in a trigger
ORA-06512: at "PRAKASH1.TRG_BI_JOB_CONFIG", line 41
ORA-04088: error during execution of trigger
same above statement If I am running from sqlplus then It is creating job without error. If I am creating job using DBMS_JOB into trigger then It is also working fine but this package is depricated from oracle10g so I cannt use it any more.
My Oracle version is 'Oracle DATABASE 10g RELEASE 10.2.0.1.0 - Production'.
can anyone help me in this context.I have a few comments on this thread as an Oracle dbms_scheduler developer.
- Oracle takes backward compatibility very seriously. Although dbms_job is deprecated, the interface will continue to work indefinitely. The deprecation of dbms_job is so that customers will be encouraged to take advantage of the more powerful dbms_scheduler. It is extremely unlikely that entire blocks of functionality will ever be removed. There is currently no plan to remove dbms_job functionality (and even if there were, doing so would be strenuously opposed by many users).
- lots of internal Oracle database components are standardizing on using dbms_scheduler (resource manager, materialized views, auto sql tuning etc). This is good evidence that it will continue to be the recommended scheduling method for the foreseeable future - not even the concept of a replacement exists. It is also under active development.
- The reason for the automatic commit is that a dbms_scheduler job is a full database object like a stored procedure or a table. So a call to dbms_scheduler.create_job is like executing a DDL which takes effect immediately. A dbms_job job is mostly just a row in a table so a call to dbms_job.submit behaves like regular DML. There are many advantages to a job being a full database object but DDL behaviour is an unfortunate requirement of this.
Hope this clears a few things up, reply with any questions.
-Ravi -
PLS-00428 Error when creating a new trigger
Hi,
I'm encountering the PLS-00428 error when I run the script below.
CREATE OR REPLACE TRIGGER TIBCOUSER.po_response_trigger
BEFORE INSERT ON po_response FOR EACH ROW
BEGIN
IF:NEW.ariba_processsequence is null then
SELECT pttransid AS pttransid, 'Product Test Pass 1' AS pttransname, aribaorderid AS aribaorderid, '0' AS errorcode, '' AS MESSAGE, SYSDATE AS ariba_insertdate
FROM po_request
WHERE adb_l_delivery_status = 'N';
UPDATE po_request
SET adb_l_delivery_status = 'C'
WHERE adb_l_delivery_status = 'N';
END IF;
END;
Can someone point out what is missing or what is wrong with the script? Any help would be much appreciated.
Regards,
JiggerHi Jigger,
I was able to create the trigger using the script below.That's nice, you got the trigger created. Below is your trigger, I have added some comments.
create or replace trigger tibcouser.po_response_trigger
before insert or update
on po_response
for each row
declare
-- 1. These variables should really be anchored to po_response
-- 2. They should be named differently than columns in po_response
-- 3. It seems that you don't need them (See 7.)
pttransid integer := null;
pttransname varchar2(255) := null;
aribaorderid varchar2(255) := null;
errorcode integer := null;
message varchar2(255) := null;
ariba_insertdate date := null;
adb_l_delivery_status char(1) := null;
begin
-- 4. This is never true, since adb_l_delivery_status is null, here
-- So, I guess your trigger never does anything, so in a sense it works
if (adb_l_delivery_status = 'N')
then
-- 5. This select will raise too_many_rows, when there is more than one record in po_response.
-- 6. It seems you will have a problem with mutating table
-- 7. The select doesn't do anything, you never use any of the values selected
-- 8. The select is confusing, since variables are named equally to columns
-- 9. You select constants, why not just assign them right away
select pttransid
,pttransname
,aribaorderid
,'0'
,sysdate
into pttransid
,pttransname
,aribaorderid
,errorcode
,message
,ariba_insertdate
from po_response;
-- 10. This update will update ALL records in po_request, probably not what you want.
update po_request
set adb_l_delivery_status = 'C';
end if;
-- 11. Good practise dictates end po_response_trigger;
end;
/In general, when you think your post has been answered, then kindly mark it as such.
Regards
Peter -
Creation of db trigger with error ..
Hello All,
I am creating a trigger as shown .. but getting the following error ..
ORA-01748: only simple column names allowed here
I have a specific requirement as stated below for which i have written a trigger so when user manipulates the column p, q values in table b the corrresponding columns in table a ( x ) should be updated accordingly. I assume it should be after update on table b
a - b
x p+q
if the user updates either column p or q from table b , the trigger should fire and update the column x from table a.
i have written the trigger for this as after update on table b - is am writing a correct trigger ? that accomplishes the task ? can a create a trigger on more than one column too?
if the triggger is on more than one column , will the trigger fire for each column or for all the columns only ?
CREATE OR REPLACE TRIGGER fmlylevel_variables_trg AFTER UPDATE OF P3I2009Q2_FCI_LALA.MINC ON
SALARYX
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
BEGIN
CALL PKG_FCI_APP.update_fmly_income_variables;
-- this procedure updates the columns of table a taking columns of table b
DBMS_OUTPUT.PUT_LINE('TRIGGER FIRED UPON THE UPDATION OF THE COLUMNS ');
END ;
Can any one suggest what is the issue .. i check in google but not clear.
Edited by: kumar73 on Aug 25, 2010 10:50 AM
Edited by: kumar73 on Aug 25, 2010 10:58 AM
Edited by: kumar73 on Aug 25, 2010 11:15 AMHello All,
here is the total things in place .
If the user is updating any of the FCI_MINC columns given in brackets , the data base trigger should fire and update the FCI_FINC tables columns as specified. All the columns SALARYX, SALARYBX etc are from the user interface. the user can change any column value ...
FSALARYX (FCI_FINC) = sum(SALARYX + SALARYBX) FCI_MINC
FNONFRMX (FCI_FINC) = sum (NONFARMX + NONFRMBX) FCI_MINC
FFRMINCX (FCI_FINC) = sum (FARMINCX + FRMINCBX) FCI_MINC
FRRETIRX (FCI_FINC) = sum (RRRETIRX + RRRETRBX + SOCCRX) FCI_MINC
FINDRETX (FCI_FINC) = sum (INDRETX) FCI_MINC
FJSSDEDX (FCI_FINC) = sum (JSSDEDX) FCI_MINC
FSSIX (FCI_FINC) = sum (SSIX + SSIBX) FCI_MINC
HERE IS THE PROCEDURE.
================
create or replace
PACKAGE BODY PKG_FCI_APP AS
function chk_notnull_blank ( colname IN number ) return number is
BEGIN
if ( colname is NOT NULL and colname not in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
RETURN colname ;
else
RETURN 0;
end if;
END chk_notnull_blank;
procedure update_fmly_income_variables is
cursor c1 is select FAMID, SALARYX, SALARYBX, NONFARMX, NONFRMBX, FARMINCX, FRMINCBX, RRRETIRX, RRRETRBX, SOCRRX, INDRETX, JSSDEDX, SSIX, SSIBX from FCI_MINC ;
cursor c2 is select FAMID, FSALARYX, FNONFRMX, FFRMINCX, FRRETIRX, FINDRETX, FJSSDEDX, FSSIX from FCI_FINC ;
v_flag_boolean boolean := false;
v_famid number := 0 ;
v_temp_sum_fsalaryx number := 0;
v_temp_sum_fnonfrmx number := 0;
v_temp_sum_ffrmincx number := 0;
v_temp_sum_frretirx number := 0;
v_temp_sum_findretx number := 0;
v_temp_sum_fjssdedx number := 0;
v_temp_sum_fssix number := 0;
BEGIN
for i in c2 loop
for j in c1 loop
if ( i.famid = j.famid ) then
v_flag_boolean := true;
v_famid := j.famid;
v_temp_sum_fsalaryx := v_temp_sum_fsalaryx + chk_notnull_blank (j.SALARYX) + chk_notnull_blank (j.SALARYBX);
v_temp_sum_fnonfrmx := v_temp_sum_fnonfrmx + chk_notnull_blank(j.NONFARMX)+ chk_notnull_blank (j.NONFRMBX);
v_temp_sum_ffrmincx := v_temp_sum_ffrmincx + chk_notnull_blank(j.FARMINCX) + chk_notnull_blank(j.FRMINCBX);
v_temp_sum_frretirx := v_temp_sum_frretirx + chk_notnull_blank (j.RRRETIRX) + chk_notnull_blank(j.RRRETRBX) + chk_notnull_blank(j.SOCRRX);
v_temp_sum_findretx := v_temp_sum_findretx + chk_notnull_blank(j.INDRETX);
v_temp_sum_fjssdedx := v_temp_sum_fjssdedx + chk_notnull_blank(j.JSSDEDX);
v_temp_sum_fssix := v_temp_sum_fssix + chk_notnull_blank(j.SSIX) + chk_notnull_blank(j.SSIBX);
end if ;
end loop ;
update FCI_FINC set fsalaryx = v_temp_sum_fsalaryx WHERE famid = v_famid ;
update FCI_FINC set fnonfrmx = v_temp_sum_fnonfrmx WHERE famid = v_famid ;
update FCI_FINC set ffrmincx = v_temp_sum_ffrmincx WHERE famid = v_famid ;
update FCI_FINC set frretirx = v_temp_sum_frretirx WHERE famid = v_famid ;
update FCI_FINC set findretx = v_temp_sum_findretx WHERE famid = v_famid ;
update FCI_FINC set fjssdedx = v_temp_sum_fjssdedx WHERE famid = v_famid ;
update FCI_FINC set fssix = v_temp_sum_fssix WHERE famid = v_famid ;
v_temp_sum_fsalaryx := 0;
v_temp_sum_fnonfrmx := 0;
v_temp_sum_ffrmincx := 0;
v_temp_sum_frretirx := 0;
v_temp_sum_findretx := 0;
v_temp_sum_fjssdedx := 0;
v_temp_sum_fssix := 0;
end loop;
EXCEPTION
when others then
raise_application_error(-20006,' An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
v_err_code := SQLCODE;
v_err_msg := substr(SQLERRM, 1, 200);
INSERT INTO audit_table (error_number, error_message) VALUES (v_err_code, v_err_msg);
end update_fmly_income_variables ;
END PKG_FCI_APP ;
here is the trigger :-
============
CREATE OR REPLACE TRIGGER fmlylevel_variables_trg AFTER UPDATE OF SALARYX, SALARYBX, NONFARMX, NONFRMBX, FARMINCX, FRMINCBX, RRRETIRX, RRRETRBX, SOCRRX, INDRETX, JSSDEDX, SSIX, SSIBX
ON FCI_MINC
FOR EACH ROW
BEGIN
PKG_FCI_APP.update_fmly_income_variables;
DBMS_OUTPUT.PUT_LINE('TRIGGER FIRED UPON THE UPDATION OF THE COLUMNS ');
END ;
Here is the error :-
============
ORA-20006: An error was encountered - -4091 -ERROR- ORA-04091: table .FCI_MINC is mutating, trigger/function may not see it
Let me know if you need any informatoin.
thanks/kumar
Edited by: kumar73 on Aug 25, 2010 1:56 PM
Edited by: kumar73 on Aug 25, 2010 2:02 PM -
How to create a database trigger for automatic run statspack.snap
Hi,
I want to create a database trigger to run statspack.snap at startup.
connect /as sysdba
grant create any trigger to perfstat;
connect perfstat/perfstat
create or replace trigger auto_snap
after startup on database
begin
statspack.snap;
end;
after startup on database
error at line 2:
ora-01031: insufficient privileges
connect /as sysdba
create or replace trigger perfstat.auto_snap
after startup on database
begin
statspack.snap;
end;
Trigger created.
after shutdown and startup the database, the trigger has not been run. (no statspack snapshot)
What I have done wrong?981145 wrote:
hi... I have created a database link but it is showing some error. Can you please tell me, do we have to update the details in TNSNAMES.ora file regarding the database which i am creating now before creating database link?????
awaiting for your response,
Thanks in advanceI'm sorry, but "showing some error" is NOT an actionable error message. Why do you think we can solve your error if you don't tell us what the error is?
Yes you will need to adjust your tnsnames. When a process in a database_A accesses database_B via a dblink in database_A, the database_A is acting as a client to database_B. At that point database_A is just like sqlplus or sqldeveloper, and all tns considerations are the same. -
i have a table with the following fields
I_ID I_ID_PARENT I_Description ekey
1 1 Pageimpressions
2 1 Startpage
3 1 news
4 1 R_part
5 4 Business
6 4 Finance
7 4 Computer
8 4 carriere &
9 4 Kids
10 4 Shopping
11 4 Travel
i want a trigger which inserts a value into ekey automatically while inserting a new row into a table. the possible records for the table would be as stated abv. the value of ekey shud be some thing like parent||'0'||no.of child of that parent (ex.101,102,103,104,401...)
can u help me out in this process... i have written a code which im sending u below but gives me error
create or replace trigger DLEI_trig
before insert on D_POSITION
for each row when (new.I_ID > 0)
declare
E_key varchar2(10);
Begin
select to_char(base_key) into E_Key from (
select e1.:new.I_ID*100+ROW_NUMBER()
OVER(
PARTITION BY e1.:new.I_Description order by e1.:new.I_Description desc) base_key
from D_POSITION e1,D_POSITION e2
where e2.:new.I_ID_parent=e1.:new.I_ID) ;
:new.EKEY := E_Key;
end;
/Your hole code is a little chaotic, try something like the following:
create or replace trigger DLEI_trig
before insert on D_POSITION
for each row
Begin
select to_char(base_key)
into :new.EKEY
from (select e1.I_ID*100+ROWNUM
OVER (PARTITION BY e1.I_Description order by e1.I_Description desc) base_key
from D_POSITION e1,D_POSITION e2
where e2.I_ID_parent = :new.I_ID);
end; As soon it compiles, you can make an insert into d_position,
and THEN you'll get the table is mutating error -
and will have to change your approach anyway. -
Good day all. I have been trying to get this trigger to work for the past three hours but to no avail. I would greatly appreciate some assistance with the two errors generated from the trigger compilation please.
the code is:
CREATE TABLE "User"
( "userId" NUMBER NOT NULL ENABLE,
"userName" VARCHAR2(20) NOT NULL ENABLE,
"password" VARCHAR2(20) NOT NULL ENABLE,
"fName" VARCHAR2(30) NOT NULL ENABLE,
"lName" VARCHAR2(30) NOT NULL ENABLE,
"dob" Date NOT NULL ENABLE,
"dateCreated" DATE NOT NULL ENABLE,
"userType" VARCHAR2(20) NOT NULL ENABLE,
CONSTRAINT "USER_PK" PRIMARY KEY ("userId") ENABLE,
CONSTRAINT "uSER_FK1" FOREIGN KEY ("userType")
REFERENCES "UserTypeLookUp" ("userType") ENABLE)
CREATE SEQUENCE "User_SEQ" MINVALUE 1 MAXVALUE 9999999 INCREMENT BY 1 START WITH 1 NOCACHE NOORDER NOCYCLE
CREATE OR REPLACE TRIGGER "BI_User"
before insert on "User"
for each row
begin
select "User_SEQ".nextval into :NEW.userId from dual
end;
ALTER TRIGGER "BI_User" ENABLE;
the error when i compile the trigger is;
Line Position Text
2 35 PLS-00049: bad bind variable 'NEW.USERID'
4 1 PLS-00103: Encountered the symbol "/" when expecting one of the following: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with
When i try to do and insert on the table i get this error;
ORA-04098: trigger 'CSR.BI_User' is invalid and failed re-validation
Error Unable to process row of table User.
OKFirst close your SELECT with ";"
-
Creating a row trigger to populate the primary key
to populate the primary key of a table automatically, i created a sequence named rule_id
using the following statement:
create sequence rule_id;
and then i created a trigger to populate the primary key using the statements below:
CREATE OR REPLACE
TRIGGER RULE_ID BEFORE INSERT ON DOC_CATS_RULE_BASED_CLASS
FOR EACH ROW
BEGIN
SELECT SEQ_RULE_BASED_CLASS.NEXTVAL
INTO :new.id FROM DUAL;
END;
i took this from a books example. but it gives and error called:
Error(3,8): PLS-00049: bad bind variable 'NEW.ID'
What is wrong and what is the current way to do it?
Please help!Hi ,
The new denotes the new data values for the table relative column.....
As regards the dual is a small table in the data dictionary that Oracle and user-written programs can reference to guarantee a known result. This table has one column called DUMMY and one row containing the value X.
Regards,
Simon -
Database trigger causes error in Form
I have a database trigger on the per_performance_reviews table. When I try to save a performance review record from the forms I get the following error:
FRM-40403: A calling form has unapplied changes. Save not allowed.
Any suggestions???
Here is my trigger:
CREATE OR REPLACE TRIGGER APPS.XXPER_UPDATE_PERF_REVIEW
BEFORE INSERT ON HR.PER_PERFORMANCE_REVIEWS
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
DECLARE
l_hire_date DATE;
l_next_review_Date DATE;
l_event_type VARCHAR2(40);
BEGIN
select papf.START_DATE, pe.type
into l_hire_date, l_event_type
from per_all_people_f papf, per_performance_reviews ppr, per_events pe
where ppr.performance_review_id = :NEW.performance_review_id
and papf.person_id = ppr.person_id
and pe.event_id = ppr.event_id
and sysdate between papf.effective_start_date and papf.effective_end_date;
l_next_review_date := l_hire_date + (365 * 2);
IF l_event_type = 'APPRAISAL' THEN
:NEW.NEXT_PERF_REVIEW_DATE := l_next_review_date;
END IF;
END XXPER_UPDATE_PERF_REVIEW;There is a forms forum here too.
However this error message
FRM-40403: A calling form has unapplied changes. Save not allowed.
implies that you opend your current form without posting/commiting in the previous form. This is not allowed. Your changes never even touched the database. -
hi,
to those who helped me before:(it's the same trigger).
CREATE OR REPLACE TRIGGER log_sal_update
BEFORE UPDATE ON emp
FOR EACH ROW
WHEN ((new.sal/old.sal)>1.5)
DECLARE
v_CountRow INTEGER;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
SELECT count(1) INTO v_CountRow
FROM user_tables
WHERE table_name = 'EMP_LOG';
IF v_CountRow = 0 THEN
EXECUTE IMMEDIATE 'CREATE TABLE emp_log(
emp_id NUMBER(4),
log_date DATE,
new_salary NUMBER(7,2),
message VARCHAR2(50),
table_exists number)';
COMMIT;
END IF;
EXECUTE IMMEDIATE 'INSERT INTO emp_log VALUES (
''' || :old.empno || ''',
' || sysdate || ',
' || :new.sal || ',
' || '''SALARY HAS BEEN CHANGED'',
' || v_CountRow || ')';
COMMIT;
END;
i connected as system/manager
and that's what i recieve when the required table 'EMP_LOG' does not exist
SQL> update emp set sal=1700 where empno=7934;
update emp set sal=1700 where empno=7934
*(under sal=1700)
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "SYSTEM.LOG_SAL_UPDATE", line 11
ORA-04088: error during execution of trigger 'SYSTEM.LOG_SAL_UPDATE'
what can be wrong ?
thanksHere is what happens when I compile the trigger on my system and try to do the update. Note that I do not get
the error that you were getting (and table is created
successfully by the trigger), but I get another error
which is because your INSERT statement into the EMP_LOG
inside the trigger has a problem.
When you print the string containing the INSERT INTO EMP_LOG statement, this is what it looks like:
INSERT INTO emp_log VALUES (
'7934',
22-JAN-2003,
5000,
'SALARY HAS BEEN CHANGED',
0)
Here you can clearly see that the second value is a date
value but the opening and closing quotes are missing and
that is why In my case I'm getting the Oracle error
"column not allowed here".
Are your table and trigger in different schema than the
user issuing the UPDATE statement?
===========================================================
SQL> desc emp_log
ERROR:
ORA-04043: object emp_log does not exist
SQL> update emp set sal = 5000 where empno = 7934 ;
update emp set sal = 5000 where empno = 7934
ERROR at line 1:
ORA-00984: column not allowed here
ORA-06512: at "KKISHORE.LOG_SAL_UPDATE", line 26
ORA-04088: error during execution of trigger 'KKISHORE.LOG_SAL_UPDATE'
SQL> desc emp_log
Name Null? Type
EMP_ID NUMBER(4)
LOG_DATE DATE
NEW_SALARY NUMBER(7,2)
MESSAGE VARCHAR2(50)
TABLE_EXISTS NUMBER
SQL>
======================================================== -
Hi ,
CREATE OR REPLACE TRIGGER TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN
AFTER update ON IP_INVNTRY_CMPSTN FOR EACH ROW
Declare
vEnablePrpg varchar2(10);
pv_ErrMsg varchar2(32676);
pragma autonomous_transaction;
begin
-- send the 'component percent' value to PHD
INVNTRY.InsertInvntryCmpstn( :new.eq_name, :new.comp_prdct_name, :new.dt_tm, :new.comp_pcnt );
commit;
IF(nvl(:old.invntry_comp_pcnt,0) <> nvl(:new.invntry_comp_pcnt,0)) then
select NVL(LKP_VALUE,'TRUE') into vEnablePrpg from IP_LKP WHERE uPPER(LKP_NAME) = 'ENABLECOMPPRPG';
IF (vEnablePrpg = 'TRUE' or vEnablePrpg = 'YES') THEN
--INVNTRY.updatecompprpg(:new.eq_name, :new.comp_prdct_name, :new.dt_tm, :new.invntry_comp_pcnt);
update IP_INVNTRY_CMPSTN SET INVNTRY_COMP_PCNT = :new.invntry_comp_pcnt where DT_TM > :new.dt_tm and EQ_NAME = :new.eq_name and COMP_PRDCT_NAME = :new.comp_prdct_name;
COMMIT;
END IF;
-- COMMIT;
END IF;
exception
when too_many_rows then
Msglog.PutDebug('BF_AU_IP_INVNTRY_CMPSTN: Lookup ENABLECOMPPRPG is configured more than once');
WHEN OTHERS THEN
IF SQLCODE > -20000 THEN
pv_ErrMsg := 'Error in trigger BF_AU_IP_INVNTRY_CMPSTN while updating. Input Parameters are EqName = '''||:new.eq_name||''''||
', PrdctName = '''||:new.comp_prdct_name||''''||',Dt_tm = '''||TO_CHAR(:new.dt_tm,'YYYY-MM-DD HH24:MI:SS')||'''';
MsgLog.PutError(pv_ErrMsg);
RAISE_APPLICATION_ERROR(-20000, pv_ErrMsg);
ELSE
RAISE;
END IF;
end;
/WHEN updating any recor on the above table , Iam getting the following error
ORA-20000: Error in trigger BF_AU_IP_INVNTRY_CMPSTN while updating. Input Parameters are EqName = 'NAP_1', PrdctName = 'U-NAPHTHA',Dt_tm = '2010-02-24 01:00:00'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 31
ORA-04088: error during execution of trigger 'TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 33
ORA-04088: error during execution of trigger 'TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 33
Edited by: user8792751 on Jul 19, 2010 2:20 AMSQL> update ip_INVNTRY_CMPSTN SET INVNTRY_COMP_PCNT=23 WHERE INV_ID=5;
update ip_INVNTRY_CMPSTN SET INVNTRY_COMP_PCNT=23 WHERE INV_ID=5
ERROR at line 1:
ORA-20000: Error in trigger BF_AU_IP_INVNTRY_CMPSTN while updating. Input
Parameters are EqName = 'NAP_1', PrdctName = 'HSD',Dt_tm = '2010-01-15
10:00:00'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 31
ORA-04088: error during execution of trigger
'TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 33
ORA-04088: error during execution of trigger
'TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 33
ORA-04088: error during execution of trigger
'TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 33
ORA-04088: error during execution of trigger
'TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 33
ORA-04088: error during execution of trigger
'TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN'
ORA-06512: at "TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN", line 33
ORA-04088: error during execution of trigger
'TOTALPLANT.BF_AU_IP_INVNTRY_CMPSTN'
ORA-06512: at "
{code} -
Hi,
During the Creating Trigger, Created with Warning.
In User Errors their as display the error of
NAME TYPE SEQUENCE LINE POSITION TEXT
JOBSCHQTY TRIGGER 1 29 42 PL/SQL: ORA-00984: column not allowed here
JOBSCHQTY TRIGGER 2 26 8 PL/SQL: SQL Statement ignored
JOBSCHQTY TRIGGER 3 39 42 PL/SQL: ORA-00984: column not allowed here
JOBSCHQTY TRIGGER 4 36 8 PL/SQL: SQL Statement ignored
Trigger is :
Create or Replace Trigger JobSchQty before insert on Joschedule for each row
Declare
Qtysu Number(15,3);
RcptQty Number(15,3);
Partno Char(9);
begin
If :New.JoScheduleno > 1 Then
If :New.Unitid in (1,2) Then
Select Partnumber,Qty_Scheduled_Su into Partno,Qtysu From JoSchedule
where Unitid = :New.Unitid
and Joborderno = :New.Joborderno
and Joslno = :New.Joslno
and JoScheduleno = :New.JoScheduleno - 1;
Select Sum(Recd_qty_su) into RcptQty From Grinitem
Where Unitid = :New.Unitid
and Grinno in (select Grinno From Grinmain
Where Unitid = :New.Unitid
and Purorderno = :New.Joborderno)
and PartNumber = Partno;
If :New.Partnumber <> Partno Then
If :New.Qty_Scheduled_Su <> Qtysu Then
If Nvl(Rcptqty,0) > :New.Qty_Scheduled_Su Then
Insert into JoErrorSch (Unitid,JOBORDERNO,JOSCHEDULE,JOBSCHEDULEDT,OLD_PARTNO,NEW_PARTNO,OLDQTYSU,NEWQTYSU,RCPTQTYSU,ERRORCODE)
Values (:New.Unitid,New.JobOrderno,New.JOSCHEDULENO,:New.JOSCHEDULEDT ,Partno,:New.Partnumber,Qtysu,:New.QTY_SCHEDULED_SU,RcptQty,'Part Number Changed for Rcpt in Old');
End If;
End if;
Else
If Nvl(Rcptqty,0) > :New.Qty_Scheduled_Su Then
Insert into JoErrorSch (Unitid,JOBORDERNO ,JOSCHEDULE,JOBSCHEDULEDT ,OLD_PARTNO,NEW_PARTNO,OLDQTYSU,NEWQTYSU,RCPTQTYSU,ERRORCODE)
Values (:New.Unitid,New.JobOrderno,New.JOSCHEDULENO,:New.JOSCHEDULEDT ,Partno,:New.Partnumber,Qtysu,:New.QTY_SCHEDULED_SU,RcptQty,'Qty is Missmatch Between Prev. SCH.');
End If;
End if;
End if;
End if;
End;
Please Guidence Me.
Regards,
C V SCREATE OR REPLACE TRIGGER jobschqty
BEFORE INSERT
ON joschedule
FOR EACH ROW
DECLARE
qtysu NUMBER (15, 3);
rcptqty NUMBER (15, 3);
partno CHAR (9);
BEGIN
IF :NEW.joscheduleno > 1
THEN
IF :NEW.unitid IN (1, 2)
THEN
SELECT partnumber, qty_scheduled_su
INTO partno, qtysu
FROM joschedule
WHERE unitid = :NEW.unitid
AND joborderno = :NEW.joborderno
AND joslno = :NEW.joslno
AND joscheduleno = :NEW.joscheduleno - 1;
SELECT SUM (recd_qty_su)
INTO rcptqty
FROM grinitem
WHERE unitid = :NEW.unitid
AND grinno IN (SELECT grinno
FROM grinmain
WHERE unitid = :NEW.unitid AND purorderno = :NEW.joborderno)
AND partnumber = partno;
IF :NEW.partnumber != partno
THEN
IF :NEW.qty_scheduled_su != qtysu
THEN
IF NVL (rcptqty, 0) > :NEW.qty_scheduled_su
THEN
INSERT INTO joerrorsch
(unitid, joborderno, joschedule, jobscheduledt, old_partno,
new_partno, oldqtysu, newqtysu, rcptqtysu,
errorcode
VALUES (:NEW.unitid, :NEW.joborderno, :NEW.joscheduleno, :NEW.joscheduledt, partno,
:NEW.partnumber, qtysu, :NEW.qty_scheduled_su, rcptqty,
'Part Number Changed for Rcpt in Old'
END IF;
END IF;
ELSE
IF NVL (rcptqty, 0) > :NEW.qty_scheduled_su
THEN
INSERT INTO joerrorsch
(unitid, joborderno, joschedule, jobscheduledt, old_partno, new_partno,
oldqtysu, newqtysu, rcptqtysu, errorcode
VALUES (:NEW.unitid, :NEW.joborderno, :NEW.joscheduleno, :NEW.joscheduledt, partno, :NEW.partnumber,
qtysu, :NEW.qty_scheduled_su, rcptqty, 'Qty is Missmatch Between Prev. SCH.'
END IF;
END IF;
END IF;
END IF;
END;:new instead of new -
Need some direction. I have a user table defined that I would like to track any change in the Active column. when this occurs, I want a trigger to fire on after update to the BPF.Users table. The trigger will insert into the user_audit_log table. There is a sequence defined for that table as well. Here is the trigger:
CREATE OR REPLACE TRIGGER user_update
AFTER UPDATE OF active ON BPF.users
FOR EACH ROW
when (new.Name <> NULL)
DECLARE
currentuser CHAR(6);
timenow DATE;
BEGIN
SELECT USER INTO currentuser from DUAL;
timenow := SYSDATE;
INSERT INTO BPF.user_audit_log
VALUES (user_audit_seq.NEXTVAL, currentuser,:New.Name, timenow, 'Active Status Change');
END;
The user_audit_log table is define:
CREATE TABLE BPF.user_audit_log
(uaID NUMBER(38) PRIMARY KEY,
uacuruser VARCHAR2(20),
uachguser VARCHAR2(20),
uadate DATE,
uamsg VARCHAR2(1000)
Now for the weird part, when I create the trigger, it has compile errors but does not say what they are. I can create the trigger without the insert statement and it compiles fine. I have no idea what is wrong with it. Can anyone give me some direction? Thanks so much!Thank you for your help. It has to do with the NVARCHAR2 definition. The character values have to be in this format, n'value', in order for it to insert. Now I just have to figure out how to do that. But here is the table definition.
SQL> describe BPF.Users
Name Null? Type
USER_ID NOT NULL NUMBER(10)
NAME NOT NULL NVARCHAR2(100)
FULL_NAME NVARCHAR2(100)
EMAIL NVARCHAR2(400)
ACTIVE NOT NULL NUMBER(1)
PREFERENCES NVARCHAR2(4000)
DEFAULT_BU_ID NOT NULL NUMBER(10)
WF_USER_ID NUMBER(10)
DEFAULT_SECURITY_PROFILE_ID NOT NULL NUMBER(10)
SYSTEM NOT NULL NUMBER(1)
REPORTSTO_USER_ID NUMBER(10)
DEFAULT_FA_ID NOT NULL NUMBER(10)
USER_ATTR_1 NVARCHAR2(1000)
USER_ATTR_2 NVARCHAR2(1000)
USER_ATTR_3 NVARCHAR2(1000)
USER_ATTR_4 NVARCHAR2(1000)
USER_ATTR_5 NVARCHAR2(1000)
USER_ATTR_6 NVARCHAR2(1000)
USER_ATTR_7 NVARCHAR2(1000)
USER_ATTR_8 NVARCHAR2(1000)
USER_ATTR_9 NVARCHAR2(1000)
USER_ATTR_10 NVARCHAR2(1000)
ORIGINAL_EMAIL NVARCHAR2(200)
DEFAULT_PASSWORD NVARCHAR2(40)
Maybe you are looking for
-
I upgraded to iTunes 10.5 and now I can't back up iTunes library to disc. In previous versions it was in file>library>backup to disc. In iTunes 10.5 that is gone!
-
Function module not executing in background due to Transactional RFC error in SM58
Hi Team, I am executing a report which calls a function module in background.This in turn creates a LUW which should eventually get cleared once the processing is completed through commit statement. However LUW is going for an error whenever it gets
-
Error while starting SAP from mmc Console
Hi, I am trying to start SAP system through sapmmc, by right clicking on the System and pressing start. But getting this unknown error: Start Failed: 2 NIECONN_REFUSED (WSAETIMEOUT: Connection timed out), NRawConnect failedin plugin_fopen() Checking
-
JDBC stale connections and app hanging
Hello, After a while idle my app stop working(it actually hangs) and after waiting all I get is the following exception message: Caused by: java.sql.SQLException: Invalid or Stale Connection found in the Connection Cache at oracle.jdbc.driver.Databas
-
This apple ID has not yet been used in the iTunes store" when i am trying to download applications
"This apple ID has not yet been used in the iTunes store" when i am trying to download applications