Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: PL/SQL question

RE: PL/SQL question

From: <manoj.gurnani_at_polaris.co.in>
Date: Wed, 28 Sep 2005 19:15:29 +0530
Message-ID: <OF3EE8C67A.CEA04DA4-ON6525708A.004B62C5@polaris.co.in>

Is it possible for all detail tables be updated without using a cursor. can u explain with example.

                                                                                                                                       
                      "Kennedy, Jim"                                                                                                   
                      <jim_kennedy_at_men         To:      <manoj.gurnani_at_polaris.co.in>, <oracle-l_at_freelists.org>                        
                      tor.com>                 cc:                                                                                     
                                               Subject: RE: PL/SQL question                                                            
                      09/28/2005 07:02                                                                                                 
                      PM                                                                                                               
                                                                                                                                       
                                                                                                                                       







I don't see why you are using execute immediate. I think you could do it all in one sql statement. To quote Mr. Kyte "Row by row is slow by slow". I think you have over complicated it.
Jim

-----Original Message-----

From: oracle-l-bounce_at_freelists.org on behalf of manoj.gurnani_at_polaris.co.in
Sent: Wed 9/28/2005 6:28 AM
To: oracle-l_at_freelists.org
Subject: Re: PL/SQL question

Below is the code.
the cursor has about 300000 recs.
The details tables have large volume of data and some have about 30 recs for each ref_num in cursor.
This script has to be run .Can performance be increased. I've tested this for 3000 recs in cursor and with lesser volume of data in detail table.
time taken is 25 min.
Note :index is not present in all detail tables on column used in filter.

set timing on
set serverout on size 1000000
declare

l_commit_interval number := 5000;
l_where_clause varchar2(2000);
l_cnt number := 0;
l_owner varchar2(25) := 'OWNER1';
l_index_cnt number := 4;

type txn_rec_tab_cnt is record
(
 tab_name varchar2(70),
 tab_aff_rows number(6):= 0
);
type t_tab_cnt is table of txn_rec_tab_cnt index by binary_integer; txn_tab_cnt t_tab_cnt;
cursor c1 is
select ref_num from trans
where country_code = 'KK';
cursor c2 is
select a.owner||'.'||a.table_name table_name,b.column_name from all_tab_columns a,all_tab_columns b where a.column_name = 'CTRY'
and a.table_name = b.table_name
and b.column_name in ('REF_NUM','BILL_REF_NUM','FLDR_T2_ID','TXN_REF_NUM')
and a.owner = l_owner
and b.owner = l_owner;

begin
for curs1 in c1 loop
l_cnt := l_cnt + 1;
l_index_cnt := 4;
for curs2 in c2 loop
l_where_clause := ' where '||curs2.column_name || ' = :col1'; execute immediate 'update '||curs2.table_name||' set ctry_cd = ''KK'''|| l_where_clause
using curs1.ref_num;

txn_tab_cnt(l_index_cnt).tab_name := curs2.table_name;
txn_tab_cnt(l_index_cnt).tab_aff_rows:=
txn_tab_cnt(l_index_cnt).tab_aff_rows+sql%rowcount;
l_index_cnt := l_index_cnt + 1;
end loop;
if mod(l_cnt,l_commit_interval) = 0 then commit;
end if;
end loop;
commit;
for j in 1..txn_tab_cnt.count loop
dbms_output.put_line('No of rows updated in '||txn_tab_cnt(j).tab_name||' = '||txn_tab_cnt(j).tab_aff_rows);
end loop;
end;
/
                      rjamya

                      <rjamya_at_gmail.com>         To:
manoj.gurnani_at_polaris.co.in
                      Sent by:                   cc:
oracle-l_at_freelists.org
                      oracle-l-bounce_at_fr         Subject: Re: PL/SQL
question
                      eelists.org



                      09/28/2005 06:42

                      PM

                      Please respond to

                      rjamya






You don't show us the code, you don't tell us what version,platform, you don't tell us how much time it takes and you don't tell us how much time ti should take.

Sorry, the crystal ball is broken, come back in 3 weeks.

ps: 1 lakh is one hundred thousand.
Raj

On 9/28/05, manoj.gurnani_at_polaris.co.in <manoj.gurnani_at_polaris.co.in > wrote:

Hi,

      I've a cursor which retrieves about 3 lakh recs from a table.(master)

based on column value retrieved from cursor for each rec,there are other tables (detail) to be updated.
The detail tables have large volumes of data. the question is how can the performance be improved to achieve the desired result.

This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in
--

http://www.freelists.org/webpage/oracle-l

This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited.

Visit Us at http://www.polaris.co.in
--

http://www.freelists.org/webpage/oracle-l Received on Wed Sep 28 2005 - 08:48:09 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US