Advertisement

09.05.2008 at 05:59AM PDT, ID: 23706037
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

please tune this pl/sql code

Asked by new2plsql in Oracle 10.x

Tags: , ,

the above code takes 45 mins to 75 mins to execute and needs to be tuned.
any advice will be appreciatedStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
| 1)Create a supvervisor hierarchy to roll-up employees and contingents |
|   with level mgrs.                                                    |
WHENEVER SQLERROR EXIT SQL.SQLCODE;
WHENEVER OSERROR EXIT SQL.OSCODE;
SET SERVEROUTPUT ON;
 
TRUNCATE TABLE gemprod.t_agg_pmtree
/
 
DECLARE
 
     v_ceoid   CHAR(8) ; 
   
   /* LOG VARIABLES */
   n_ins_cnt      NUMBER := 0;
   n_counter      NUMBER := 0;
   n_errors       NUMBER := 0;
   ora_msg        VARCHAR2(100);
   idx_dups       NUMBER :=0;   
         
   upd_count      NUMBER := 0;  -- counter for number records processed       
   i_rpt          NUMBER := 0;  -- counter for number of reports in chain     
   v_prev_supv_id CHAR(8) ;     -- saves previous supvervisor id             
   v_supv_id      CHAR(8);      -- saves search by supvervisor id             
   temp_emp       CHAR(8);
   temp_sup       CHAR(8);
   i_rpt_level    NUMBER := 0;  -- saves rpt level; below CEO is Level 1     
   i_chld_level   NUMBER := 0;  -- saves rpt level; immediate supv is Level 1
     
   CURSOR c1 IS
      SELECT (LEVEL - 1) AS rptlevel
             ,emplid
             ,supervisor_id
             ,reg_temp
      FROM   (SELECT  emplid
                     ,DECODE(emplid,v_ceoid,'99999999',supervisor_id) AS supervisor_id  
                     ,reg_temp
              FROM    gds_t_employee
              WHERE   supervisor_id IS NOT NULL
              AND     empl_status IN ('A','L','P')
              UNION ALL
              SELECT  emplid
                     ,supervisor_id
                     ,'C' AS reg_temp
              FROM    gds_t_contingent
              WHERE   supervisor_id IS NOT NULL
              AND     empl_status IN ('A','L','P'))
      WHERE emplid <> v_ceoid
      START WITH  emplid = v_ceoid
      CONNECT BY PRIOR emplid = supervisor_id; 
       
BEGIN
 
 
 
   BEGIN
  
    SELECT EMPLID into v_ceoid from CEO_TBL;
 
   EXCEPTION
   WHEN OTHERS THEN
     ora_msg := SUBSTR(SQLERRM(SQLCODE),11,100);
     raise_application_error(-20010,ora_msg ||' :: '||' Problem with CEO_TBL');
   END;
 
   FOR v_c1 IN c1 LOOP
      /*initialize variables*/
      v_supv_id      := NULL; 
      v_prev_supv_id := NULL;  
      i_rpt_level    := 0;
      i_rpt          := v_c1.rptlevel;
      i_chld_level   := 0;
 
      FOR i in 1..i_rpt loop
         i_rpt_level  := (i_rpt - i);
         i_chld_level := i;
           
         --first time through loop use immediate supervisor
         --subsequent times use previous supvid
         IF i = 1 THEN 
            v_supv_id := v_c1.emplid;                
         ELSE
            v_supv_id := v_prev_supv_id;    
         END IF; 
  
         BEGIN
            IF v_c1.reg_temp IN ('R','T') THEN
               SELECT supervisor_id 
               INTO   v_supv_id
               FROM   gds_t_employee
               WHERE  emplid = v_supv_id;
            ELSE
               BEGIN
                  SELECT supervisor_id
                  INTO   v_supv_id
                  FROM   gds_t_contingent
                  WHERE  emplid = v_supv_id;
               EXCEPTION
                  WHEN NO_DATA_FOUND THEN
                     SELECT supervisor_id
                     INTO   v_supv_id
                     FROM   gds_t_employee
                     WHERE  emplid = v_supv_id;
               END;
            END IF;
         EXCEPTION
             WHEN OTHERS THEN
                v_supv_id := '99999999';
         END;
         
         temp_emp := v_c1.emplid;
	 temp_sup := v_c1.supervisor_id;
                
         v_prev_supv_id := v_supv_id;
 
         BEGIN
            INSERT INTO gemprod.t_agg_pmtree 
               VALUES (v_supv_id,     --SUPVERVISOR ID 
                       v_c1.emplid,   --CHILD EMPLID    
                       i_rpt_level,   --EQUATES TO THE TOTAL NUMBER OF REPORTS A PERSON HAS
                       i_chld_level,  --INCREMENTED UP FROM IMMEDIATE SUPV 
                       SYSDATE);      --TODAY'S DATE  
                
            n_counter := n_counter + 1;
            n_ins_cnt := n_ins_cnt + 1; 
 
         EXCEPTION
            WHEN DUP_VAL_ON_INDEX THEN
               idx_dups := idx_dups + 1;
            WHEN OTHERS THEN
               ora_msg := SUBSTR(SQLERRM(SQLCODE),11,100);
               DBMS_OUTPUT.PUT_LINE(ora_msg || ' v_c1.emplid: ' || v_c1.emplid);
                 n_errors := n_errors + 1;
         END;
 
         IF n_counter > 5000 THEN
            n_counter := 0;
            COMMIT;
         END IF;
      END LOOP;
   END LOOP;
   COMMIT;
EXCEPTION
   WHEN OTHERS THEN
      DBMS_OUTPUT.PUT_LINE(SQLERRM(SQLCODE) || ' LOAD_AGG_PMTREE');
      DBMS_OUTPUT.PUT_LINE(ora_msg || ' v_c1.emplid: ' || temp_emp );
      DBMS_OUTPUT.PUT_LINE(ora_msg || ' v_c1.emplid: ' || temp_sup );
      RAISE_APPLICATION_ERROR(-20100, ' LOAD_AGG_PMTREE');
END;
/
 
EXIT;
[+][-]09.05.2008 at 07:14AM PDT, ID: 22399151

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Oracle 10.x
Tags: ORACLE, oracle 10g, 10g
Sign Up Now!
Solution Provided By: dvz
Participating Experts: 3
Solution Grade: A
 
 
[+][-]09.05.2008 at 07:42AM PDT, ID: 22399460

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.05.2008 at 07:48AM PDT, ID: 22399528

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]09.05.2008 at 07:52AM PDT, ID: 22399582

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.05.2008 at 07:55AM PDT, ID: 22399623

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.05.2008 at 02:58PM PDT, ID: 22404218

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]11.04.2008 at 06:09PM PST, ID: 22882715

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
[+][-]11.08.2008 at 06:59AM PST, ID: 22912664

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 7-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628