Home » RDBMS Server » Performance Tuning » Procedures not getting executed (Oracle 9.2.0.8 (HP-UX))
Procedures not getting executed [message #475179] Mon, 13 September 2010 08:34 Go to next message
indrajit2002
Messages: 53
Registered: November 2007
Location: INDIA
Member
Hi,
I have two procedures which gets running for ever and do not execute.I am totally clueless about what could be the issue.Please help.

The two procedures are,

1. CREATE OR REPLACE procedure MDM_DBA.upd_icd_stats_with_mip as

v_icd_group ees_icd_9_group.icd_group%type;

cursor cur_icd_groups is
select distinct icd_group from ees_icd_9_group
order by icd_group;

begin

update ees_icd_stats e
set mip_yn = 'Y'
where
mip_yn is null
and icd_code in (select icd_code from ees_icd_9_code where mip_yn = 'Y');
commit;

open cur_icd_groups;

loop
fetch cur_icd_groups into v_icd_group;
exit when cur_icd_groups%NOTFOUND;

update ees_icd_stats e
set mip_yn = 'Y'
where
icd_code like v_icd_group || '%'
and icd_code not in (select icd_code from ees_icd_9_code where mip_yn = 'Y')
and exists (select 1 from ees_charge_master c where c.pdct_cat = 'Trocar' and e.pat_key = c.pat_key)
and mip_yn is null;
commit;

update ees_icd_stats e
set mip_yn = 'N'
where
icd_code like v_icd_group || '%'
and icd_code not in (select icd_code from ees_icd_9_code where mip_yn = 'Y')
and mip_yn is null;

commit;

end loop;

close cur_icd_groups;

end;
/


2. CREATE OR REPLACE procedure MDM_DBA.upd_energy_master_with_mip as

v_pat_key ees_energy_master.pat_key%type;
v_icd_code ees_energy_master.icd_code%type;
lap_charges number;

v_mip_yn ees_energy_master.mip_yn%type;

cursor cur_energy_master is
select distinct pat_key, icd_code from ees_energy_master where
icd_code not in ('68.51', '68.31', '68.41', '68.61', '68.71', '45.81', '48.51', '48.42', '17.31', '17.32',
'17.33', '17.34', '17.35', '17.36', '17.39', '32.41', '32.30', '32.50', '32.20', '32.25', '32.28', '33.27')
and mip_yn is null;

begin
open cur_energy_master;


loop
fetch cur_energy_master into v_pat_key, v_icd_code;
exit when cur_energy_master%NOTFOUND;


select count(1) into lap_charges
from ees_charge_master ch
where
ch.pat_key = v_pat_key
and ch.pdct_cat = 'Trocar';


if lap_charges > 0
then
v_mip_yn := 'Y';
else
v_mip_yn := 'N';
end if;


update ees_energy_master
set mip_yn = v_mip_yn
where pat_key = v_pat_key
and icd_code = v_icd_code;


end loop;


close cur_energy_master;


update ees_energy_master
set mip_yn = 'Y'
where icd_code in ('68.51', '68.31', '68.41', '68.61', '68.71', '45.81', '48.51', '48.42',
'17.31', '17.32', '17.33', '17.34', '17.35', '17.36', '17.39', '32.41', '32.30', '32.50', '32.20', '32.25', '32.28', '33.27');


commit;


end;
/
Re: Procedures not getting executed [message #475180 is a reply to message #475179] Mon, 13 September 2010 08:49 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Since NOBODY can optimize SQL just by looking at it, we need a few more details.
http://www.orafaq.com/forum/m/433888/136107/#msg_433888
Please refer to URL above & be sure to provide the details requested:
Re: Procedures not getting executed [message #475184 is a reply to message #475180] Mon, 13 September 2010 09:13 Go to previous messageGo to next message
Michel Cadot
Messages: 68648
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
do not execute.I am totally clueless about what could be the issue

And so why can't we with what you posted?
Hint: a procedure does not execute by itself, you have to call it.

Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version, with 4 decimals.

Use SQL*Plus and copy and paste your session, the WHOLE session including procédure creation and line numbers and so on.

Regards
Michel


Re: Procedures not getting executed [message #475188 is a reply to message #475180] Mon, 13 September 2010 09:20 Go to previous message
cookiemonster
Messages: 13921
Registered: September 2008
Location: Rainy Manchester
Senior Member
Getting rid of the loops and cursors would be a good start. Both procedures can be rewritten as a couple of update statements with nothing else needed.
Previous Topic: Standard vs Advanced Compression
Next Topic: Need to tune query
Goto Forum:
  


Current Time: Sun May 05 10:00:00 CDT 2024