Calling procedures in trigger
Hi
have two procedures desig_updation and increment_process. desig_updation should fire first and have to update records marked for update. Increment process have to increment salary based on desig updation . incrementprocess should fire for every record that is updated by desig_updation procedure . which trigger suite for increment process ?
rinz
Edited by: Rinz on Apr 25, 2010 2:41 PM
hi
data is not commiting in db when i teried with on-update and pre-update trigger
PROCEDURE increment_process IS
m_gross_sal number;
p_rslt varchar2(200);
p_status varchar2(20);
BEGIN
delete from INCR_TEMP where ECODE = :emp_code ;
m_gross_sal := aod_gross_salary(:emp_orgn,:emp_code,'A');--find current salary
insert into INCR_TEMP(ECODE , CURR_SAL ,
INCREMENT_AMT ,TOTAL_AOD,
STATUS,INCR_TYPE)
values(:emp_code,m_gross_sal,
:incr_amt,m_gross_sal+:incr_amt,
'N','I');
forms_ddl('commit');
update_emp_increment(:emp_orgn,:emp_code,
TRUNC(to_date(to_char(:new_Date,'DD/MM/YYYY'),'DD/MM/YYYY')),null,
:incr_amt, p_rslt,
:parameter.p_user,to_date(to_char(SYSDATE,'DD/MM/YYYY'),'DD/MM/YYYY'),'I',
p_status);
END;
PROCEDURE desig_updation IS
V_count number := get_block_property('employee_master',query_hits);
BEGIN
go_block('employee_master');
first_record;
for i in 1.. V_count loop
if((:desig is not null ) and (:new_date is not null) and (:emp_desig<>:desig) and (:new_date >=:emp_desig_date)) then
:emp_desig :=:desig;
:emp_grade:=:grade;
:emp_desig_date:=:new_date;
:emp_upd_by:=:global.usr;
:emp_upd_on:=:system.current_datetime;
if( (:radio_group=2) and (:incr_amt is not null)) then
increment_process;
end if;
end if;
if :system.last_record ='TRUE' then exit;
else
next_record;
end if;
end loop;
END;
Similar Messages
-
How to Call Procedure from Trigger body?
I have a procedure that works which I tested from sqlplus with 'exec proc_name;'
what I want is to call this procedure from the trigger and pass the parameters to the proc. the trigger fires AFTER INSERT of certain table and I want to pass those just added attribute values to the proc.
please help.
I have tried to do 'exec proc_name' from the trigger but it does not work?You don't use exec within pl/sql, just proc_name followed by your parmateters. From within a trigger, the just added values will be :new.column_name. So, you would have something like:
CREATE OR REPLACE TRIGGER your_trigger_name
AFTER INSERT ON your_table_name
FOR EACH ROW
BEGIN
proc_name (:NEW.column_name1, :NEW.column_name2);
END your_trigger_name;
/You will need to have corresponding input parameters in your proc_name procedure, something like:
CREATE OR REPLACE PROCEDURE proc_name
(p_column_name1 your_table_name.column_name1%TYPE,
p_column_name2 your_table_name.column_name2%TYPE)
AS
BEGIN
-- whatever processing you want to do
END proc_name; -
Dear Sir
How to call a Procedure in Trigger and if any exception occurs in trigger then How do we rollback it?
Regards
Thakur Manoj R[email protected] wrote:
Dear Sir
How to call a Procedure in Trigger Just call it by passing its parameters.
and if any exception occurs in trigger then How do we rollback it?You dont have to rollback. Trigger depends on the parent transaction. So if you just allow the raise the exception it will automatically rollback. -
Common procedure call from db trigger.
hi all,
i have one procedure, which is called from most of the db-triggers on tables.
while dml operation, db-trigger on table calls this common procedure.
while executing this procedure, i want to know currently, it is called from which trigger and table.
is it possible?
regards.in that case i have to modify all the triggers on table, which is labourious job.
any other solution. -
Need to do a commit in a procedure called from a trigger
How do I get around the need to do a commit in a procedure that is being executed from a trigger. I know it can't be done but I bet someone has a workaround. Thanks.
Hi
Why do you want to do a commit in a procedure called from a trigger?
Anyway if you are running Oracle 8i+ you can declare the procedure as an Autonomous Transaction and can issue a commit, eventhough it is called from a trigger.
HTH
Arvind Balaraman -
Question about call statement in trigger
I faced a question in written exam.
A CALL statement inside a trigger allow us to call
a)package
b)procedure
c)function
d)another trigger
Can anyone give me answer with reason?
I used CALL statement inside trigger but not allowing to use it. Might be earlier in oracle CALL statement we can use..its only a guess so I am asking in forum..
plz guide me..
rgds,
pcYou can use CALL in a trigger without resorting to EXECUTE IMMEDIATE
SQL> create table t1 (
2 col1 number
3 );
Table created.
SQL> create procedure t1_proc
2 as
3 begin
4 dbms_output.put_line( 'In T1_PROC' );
5 end;
6 /
Procedure created.
SQL> ed
Wrote file afiedt.buf
1 create trigger trg_t1
2 before insert on t1
3 for each row
4* call t1_proc
5 /
Trigger created.
SQL> set serveroutput on;
SQL> insert into t1 values( 1 );
In T1_PROC
1 row created.I can't think of any reason that you'd actually intentionally structure your code this way in this day and age because it would be rather likely to cause confusion for whoever had to support this in the future. But it is valid syntax that probably made sense back in Oracle 5.
Justin -
Call procedure within procedure
Hai
I have some question
1)
This below procedure create user at run time
============================================
create or replace procedure new_u1( p_name in varchar2,
p_pw in varchar2,
p_def_tblspace in varchar2 default 'users' )
as
begin
execute immediate 'create user ' || P_name || ' identified by ' ||
p_pw || ' default tablespace ' || p_def_tblspace ||
' temporary tablespace temp';
execute immediate 'grant create session to ' || p_name;
end;
This below procedure create tables at run time
==============================================
create or replace procedure M2 (table_name varchar2) as
cursor1 integer;
begin
cursor1 := dbms_sql.open_cursor;
dbms_sql.parse(cursor1, 'DROP TABLE ' || table_name,
dbms_sql.v7);
dbms_sql.close_cursor(cursor1);
end;
I want ,when first procedure calls ,it calls second procedure and create tables in that schema (call procedure within procedure).How to do that?
2)What is diffrenece between row and statement level trigger?how many types of triggers?
3)what is mutating trigger or table?
4)dbms_stats.gather_table_stats package it collects the statistics about the tables .I want statistics to be collected at every day 9am and 7pm how to do that?
Thanks in advance
MohanYou could use an expression like this, to generate the run times:
SQL> create table times (dt date) ;
Table created.
SQL> BEGIN
2 FOR idx IN 1 .. 24
3 LOOP
4 INSERT INTO times VALUES (trunc(SYSDATE) + (idx / 24));
5 INSERT INTO times VALUES (trunc(SYSDATE) + (idx / 24) + (1 / (24 * 60)));
6 INSERT INTO times VALUES (trunc(SYSDATE) + (idx / 24) + (59 / (24 * 60)));
7 END LOOP;
8 END;
9 /
PL/SQL procedure successfully completed.
SQL>
SQL> SELECT to_char(dt,
2 'dd-mon-yyyy hh:mi:ss AM'),
3 to_char(decode(sign(to_number(to_char(dt,
4 'hh24MI')) - 900),
5 -1,
6 trunc(dt) + (9 / 24),
7 0,
8 trunc(dt) + (9 / 24),
9 decode(sign(to_number(to_char(dt,
10 'hh24MI')) - 1900),
11 -1,
12 trunc(dt) + (19 / 24),
13 0,
14 trunc(dt) + (19 / 24),
15 trunc(dt) + 1 + (9 / 24))),
16 'dd-mon-yyyy hh:mi:ss AM')
17 FROM times
18 ORDER BY dt
19 /
TO_CHAR(DT,'DD-MON-YYYY TO_CHAR(DECODE(SIGN(TO_
01-jan-2004 01:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 01:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 01:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 02:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 02:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 02:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 03:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 03:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 03:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 04:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 04:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 04:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 05:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 05:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 05:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 06:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 06:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 06:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 07:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 07:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 07:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 08:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 08:01:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 08:59:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 09:00:00 AM 01-jan-2004 09:00:00 AM
01-jan-2004 09:01:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 09:59:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 10:00:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 10:01:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 10:59:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 11:00:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 11:01:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 11:59:00 AM 01-jan-2004 07:00:00 PM
01-jan-2004 12:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 12:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 12:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 01:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 01:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 01:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 02:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 02:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 02:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 03:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 03:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 03:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 04:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 04:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 04:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 05:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 05:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 05:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 06:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 06:01:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 06:59:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 07:00:00 PM 01-jan-2004 07:00:00 PM
01-jan-2004 07:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 07:59:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 08:00:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 08:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 08:59:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 09:00:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 09:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 09:59:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 10:00:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 10:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 10:59:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 11:00:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 11:01:00 PM 02-jan-2004 09:00:00 AM
01-jan-2004 11:59:00 PM 02-jan-2004 09:00:00 AM
02-jan-2004 12:00:00 AM 02-jan-2004 09:00:00 AM
02-jan-2004 12:01:00 AM 02-jan-2004 09:00:00 AM
02-jan-2004 12:59:00 AM 02-jan-2004 09:00:00 AM
72 rows selected.
SQL> -
How to Call Procedure or Function
Hi,
How to call a procedure or function in apex, Please let me know
Thanks
SudhirHi,
This post might help
Re: How to Call procedure In Processes
Regards,
Jari -
How to kill a session in stored procedure or trigger.
Can anyone let me know, how to kill a particular session in stored procedure or trigger.
Regards
KVSSalso you cannot attempt to kill ur own current session.
But on what circumstances you want to kill the session.
When anyone trys to access a table and lets suppose the trigger onthat table activates
and you want to kill that very session which activated the trigger ???
i dont think its possible. To kill a session definitely you should be in a different session and
then only you can achieve that.
pls check it out
prakash
[email protected] -
Hi i am using oracle 10g how to view the content of the stored procedure or trigger ?
Hi i am using oracle 10g .How to edit the content of the stored procedure or trigger ?
jklopkjl wrote:
Hi i am using oracle 10g .How to view the content of the stored procedure or trigger ?
query ALL_SOURCE
SQL> desc all_source
Name Null? Type
OWNER VARCHAR2(30)
NAME VARCHAR2(30)
TYPE VARCHAR2(12)
LINE NUMBER
TEXT VARCHAR2(4000) -
Rename view,procedure,function,trigger in oracle.
hi all,
Just i am thinking a concept in oracle.
can i rename view,procedure,function,trigger in oracle. i know it is not possible bcos it is a script.
can u please confirm meYou can rename View
http://download.oracle.com/docs/cd/B12037_01/server.101/b10759/statements_9019.htm
You can rename Trigger
http://www.ss64.com/ora/trigger_a.html
Well there we go. Having never had a need to do it myself (I put it down to good design and coding standards!) I never knew it was possible.
;-)) -
Getting NLS setting issues when calling procedure
Hi,
Can anybody suggest me what could the problem in the below issue?.
i am invokeing procedure using DBAdapter. My soa version is 11.1.1.5. When i am calling procedure first time it is working fine. But when i am invoke second time
it is showing below error. I observed that i am getting error alternativly. So kinldy advice me what could be the issue.
Error:
Cause: java.sql.SQLException: ORA-20001: Oracle error -20001: ORA-20001: Oracle error -2074: ORA-02074: cannot SET NLS in a distributed transaction has been detected in fnd_global.set_nls.set_parameter('NLS_LANGUAGE','AMERICAN'). has been detected in fnd_global.set_nls. ORA-06512: at "APPS.APP_EXCEPTION", line 72 ORA-06512: at "APPS.FND_GLOBAL", line 240 ORA-06512: at "APPS.FND_GLOBAL", line 1410 ORA-06512: at "APPS.FND_GLOBAL", line 1655 ORA-06512: at "APPS.FND_GLOBAL", line 2171 ORA-06512: at "APPS.FND_GLOBAL", line 2313 ORA-06512: at "APPS.FND_GLOBAL", line 2251 ORA-06512: at
Regards,
AdhiHi:
Another way to avoid this, is to use an Non-XA Datasource.
Hope this helps
best -
How I call procedure in interactive report??
Hi
Is possible that call procedure in interactive report on APEX?
Because
in region source it asked only sql statement so I am confused and I dont know how call procedure in interactive report ?
Edited by: esra aktas on 12.May.2011 11:04
Edited by: esra aktas on 12.May.2011 12:05I am confused... Now, acoording to my senior porject in school my advisor want to that lots of procedures' name and arguments that I have collect them in a table. I collected procedures in table then I wrote a procedure that call wanted procedure by using dynamic sql and run that procedure..I select procedure name on selectlist on apex then that procedure run.
So I want to my procedure's results must be as dataset in report . But report's source want to sql statement but I want to call the procedure as I mentioned.
If you have any idea about my situations , I want to get your adviced.
I have a this procedure.
create or replace
PROCEDURE CALLSPFROMTABLE(id number,arg1 varchar2,arg2 varchar2) as
table_name varchar2(30):='procedures';
procname varchar2(1000);
begin
EXECUTE IMMEDIATE 'select procname from ' || table_name || ' where id='||id into procname;
EXECUTE IMMEDIATE 'BEGIN '||procname||'('||arg1||','||arg2||'); END;';
END;id=>:p1_SP , arg1=>:P1_YIL arg2=>:P1_BIRIM from selectlists
Edited by: esra aktas on 12.May.2011 13:08
Edited by: esra aktas on 12.May.2011 13:17 -
Call procedure while creating view in hana.
Can we call procedure while creating a attribute view like
CREATE VIEW "PAYROLLDBTEST"."@HourTransactionView"
"DocEntry",
"DocNum",
"EmpID",
"EmpCode",
"FullName",
"TableName",
"TranName",
"U_FromDate",
"U_ToDate",
"NoOfDays",
"U_FromTime",
"U_ToTime",
"NoOfHours",
"OvertimeHours",
"UnpaidDays",
"Weekends",
"Holidays",
"U_Remarks",
"U_BatchNo",
"ProjectCode"
) AS SELECT
T0."DocEntry" AS DocEntry,
T0."DocNum" AS DocNum,
T0."U_EmpCode" AS EmpID,
CALL PAYROLLDBTEST.GetEmpCodeFromEmployeeID('EmpID') , (getting syntax error here).
GetEmployeeFullName("@TRANSACTION_HOURS".U_EmpCode) AS FullName,
T0."U_TransactionType" AS TranCode,
GetHourTableName("U_TransactionType") AS TableName,
GetHourTransactionName("U_TransactionType") AS TranName,
T0."U_FromDate",
T0. "U_ToDate",
DAYS_BETWEEN("U_FromDate", "U_ToDate") + 1 AS NoOfDays,
T0."U_FromTime" AS U_FromTime,
T0."U_ToTime" AS U_ToTime,
IFNULL("U_WorkHours", 0) AS NoOfHours,
IFNULL("U_OvertimeHours", 0) AS OvertimeHours,
IFNULL("U_PaidDays", 0) AS PaidDays,
IFNULL("U_UnpaidDays", 0) AS UnpaidDays,
IFNULL("U_WeekendsCount", 0) AS Weekends,
IFNULL("U_HolidaysCount", 0) AS Holidays,
T0."U_Remarks",
T0."U_BatchNo",
T0."U_ProjectCode" AS "ProjectCode"
FROM
"@TRANSACTION_HOURS" T0
INNER JOIN
"OHEM" T1
ON
T1."empID" = T0."U_EmpCode";Hello,
The problem could be a SAPGUI related problem... Whats the current sapgui patch level ? Does it work when you try on another wokstation with the same user ?
Could you please use SAPGUI 720 and update your patch level to 7 ? Then check the behaviour again.
Best regards
Rene -
Exception handling in calling procedure
Hi,
i have a package where currently am making calls to private procedures from public procedure.
and the senario is:-
create package body p_tst
is
ex_failed exception;
-- this is private proc
procedure p_private
is
begin
raise ex_failed;
exception
when ex_failed
then
raise;
end p_private;
procedure p_public
is
begin
-- nomaking call to private
-- procedure
p_private;
-- here i need to catch
-- the raised exception
-- passed from the called
-- procedure
when ex_failed
end p_public;
end;
basically i want to catch the exception being passed from called procedure to calling procedure, and raise the same exception in calling procdure.
is it possible to catch the same exception in the calling procedure?Yes, you can catch the same exception in the calling procedure, exceptions are propagated to the caller if they are not handled in the called procedure.
Is this what you are trying to do?
CREATE OR REPLACE PACKAGE p_tst
AS
PROCEDURE p_public;
ex_failed EXCEPTION;
END;
CREATE OR REPLACE PACKAGE BODY p_tst
IS
PROCEDURE p_private
IS
BEGIN
RAISE ex_failed;
END p_private;
PROCEDURE p_public
IS
BEGIN
p_private;
EXCEPTION
WHEN ex_failed
THEN
DBMS_OUTPUT.put_line ('error');
END p_public;
END;
SQL> set serveroutput on;
SQL> exec p_tst.p_public;
error
PL/SQL procedure successfully completed.
Maybe you are looking for
-
Hi, What is the transaction to modify a table (oracle) ? Thanks in advance
-
EHP4 Talent Management business function CA_HAP_CI_1
Hi We have applied EHP4 and have ECC6 Basis 701 SP6 and HR 604 SP24 and Netweaver EP7. Has anyone experience of acitivating business function CA_HAP_CI_1. I have researched this functionality and know of SAP notes 1239427 and 1239426. It would be mos
-
Why ipod can't receive emAIL AD HARD TO FIX IT
I TRIED MANY WAYS BUT CAN'T FIX IT, DOES ANY ONE HAS THE SAME EXPERIENCES?
-
Hello, I keep getting contact requests fro us soldiers in Afganistan and don´t know how to stop them!Add me to you contact etc... I tried privacy in my setting, but somehow did´t succeed. Solved! Go to Solution.
-
Migrate one HDD to different Storage
Hi Guys, in our LAB we have two VMS with two differents HDD attached it to it, lately we have attached extra storage and want to move one HDD to different storage Disk 1 is 40 GB on the SSD Hard disk Disk 2 is 1TB on Sata Hard Disk. I want to move