Advertisement

06.18.2008 at 03:40PM PDT, ID: 23497177
[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.4

Oracle Cursor Hangs After Certain Number of Rows (about 76 in this case)

Asked by robrubin in Oracle 10.x, Oracle 9.x, PL / SQL

Tags: , , , ,

We have a cursor that selects 1 field (ID) and then runs a complex insert statement where it inserts that ID along with other information from a more complex SELECT.

If we limit the number of rows returned from the cursor's select statement to about 76, the procedure executes fine within about 2 seconds.  As soon as we increase the number of rows returned to 77 or higher, the procedure just hangs with no response.

The code is below.  I just don't understand how it can be perfectly fine up to 76 rows and then the next row would cause it to hang.  

The entire code is:

DECLARE
  type r_cursor is REF CURSOR;
  c1 r_cursor;
  v_prjid srm_projects.id%type;
 

 
 BEGIN
 

    OPEN c1 FOR
    SELECT id
     FROM ( SELECT DISTINCT 1 seq,
                            id
            FROM srm_projects
              WHERE unique_name IN ( SELECT DISTINCT bhi_bot_bas_proj
                                     FROM ODF_CA_INCIDENT  )
            UNION
            SELECT 2 seq,
                   id
            FROM ODF_CA_PROJECT
              WHERE PARTITION_CODE = 'BOT_IT_PARTITION' ) PRJLIST
      WHERE ROWNUM < 76 and id not in (5028787)
     ORDER BY id,seq;



 
 

   EXECUTE IMMEDIATE ' TRUNCATE TABLE BHI_PROJECT_BaselineActualsETC ';

 
   LOOP
     
        FETCH c1 INTO v_prjid;
        EXIT WHEN c1%NOTFOUND;
       
     
         INSERT INTO BHI_PROJECT_BaselineActualsETC
           ( SELECT *
             FROM ( SELECT 0 projsub,
                          v_prjid PID,
                           srm_projects.id prj_id,
                           NULL SubprojCount,
                           srm_projects.unique_name,
                           srm_projects.NAME prj_name,
                           (BASEREC.USAGE_SUM / 3600) / PRJ_HPD_FACTOR_FCT() baseline,
                           ( SELECT actsum
                             FROM prj_project_actsum_v
                               WHERE id = SRM_PROJECTS.id ) actuals,
                           ( SELECT estsum
                             FROM prj_project_estsum_v
                               WHERE id = SRM_PROJECTS.id ) etc
                    FROM odf_ca_project ,
                         PRJ_PROJECTS ,
                         SRM_PROJECTS ,
                         PRJ_PROJECTS PR1
                           LEFT JOIN PRJ_BASELINE_DETAILS BASEREC
                            ON ( BASEREC.BASELINE_ID = PR1.BASELINE_ID
                           AND BASEREC.OBJECT_TYPE = 'PROJECT' )
                      WHERE srm_projects.id = prj_projects.prid
                              AND srm_projects.id = odf_ca_project.id
                              AND SRM_PROJECTS.ID = PR1.PRID
                              AND srm_projects.id =v_prjid
                    UNION
                    SELECT 1 projsub,
                          v_prjid PID,
                           srm_projects.id prj_id,
                           ( SELECT COUNT(*)
                             FROM BHI_SubDep_Parent_v
                               WHERE parent_id = srm_projects.id ) SubProjCount,
                           srm_projects.unique_name,
                           srm_projects.NAME prj_name,
                           NVL(( SELECT Usage_Sum / 3600
                                 FROM PRJ_BASELINE_DETAILS ,
                                      PRJ_PROJECTS
                                   WHERE PRJ_BASELINE_DETAILS.BASELINE_ID = PRJ_PROJECTS.baseline_id
                                           AND PRID = srm_projects.id
             AND Object_type = 'PROJECT' ), 0) + NVL(( SELECT SUM(NVL(Usage_Sum, 0) / 3600)
                                                       FROM PRJ_BASELINE_DETAILS ,
                                                            PRJ_PROJECTS
                                                         WHERE PRJ_BASELINE_DETAILS.BASELINE_ID = PRJ_PROJECTS.baseline_id
                                                                 AND Object_type = 'PROJECT'
                                                                 AND PRID IN ( SELECT id
                                                                               FROM BHI_SubDep_Parent_v
                                                                                 WHERE parent_id = srm_projects.id ) ), 0) + NVL(( SELECT SUM(NVL(Usage_Sum, 0) / 3600)
                                                                                                                                   FROM PRJ_BASELINE_DETAILS ,
                                                                                                                                        PRJ_PROJECTS
                                                                                                                                     WHERE PRJ_BASELINE_DETAILS.BASELINE_ID = PRJ_PROJECTS.baseline_id
                                                                                                                                             AND Object_type = 'PROJECT'
                                                                                                                                             AND PRID IN ( SELECT id
                                                                                                                                                           FROM BHI_SubDep_Parent_v
                                                                                                                                                             WHERE parent_id IN ( SELECT id
                                                                                                                                                                                  FROM BHI_SubDep_Parent_v
                                                                                                                                                                                    WHERE parent_id = srm_projects.id ) ) ), 0) Baseline,
                           (NVL(( SELECT SUM(NVL(actsum, 0))
                                  FROM prj_project_actsum_v
                                    WHERE id = srm_projects.id ) + NVL(( SELECT SUM(NVL(actsum, 0))
                                                                         FROM prj_project_actsum_v act,
                                                                              BHI_SubDep_Parent_v ppv
                                                                           WHERE act.id = ppv.id
                                                                                   AND ppv.parent_id = srm_projects.id ), 0) + NVL(( SELECT SUM(NVL(actsum, 0))
                                                                                                                                     FROM prj_project_actsum_v act,
                                                                                                                                          BHI_SubDep_Parent_v ppv
                                                                                                                                       WHERE act.id = ppv.id
                                                                                                                                               AND ppv.parent_id IN ( SELECT id
                                                                                                                                                                      FROM BHI_SubDep_Parent_v
                                                                                                                                                                        WHERE parent_id = srm_projects.id ) ), 0), 0) + NVL(( SELECT NVL(ITL_GET_ACTUAL_EFFORT_FCT(OBJECT_ID), 0)
                                                                                                                                                                                                                              FROM ITL_OBJECT_ASSOCIATIONS Assoc,
                                                                                                                                                                                                                                   IMM_INCIDENTS IMM,
                                                                                                                                                                                                                                   ODF_CA_INCIDENT ODF,
                                                                                                                                                                                                                                   PRTASK TSK
                                                                                                                                                                                                                                WHERE Assoc.OBJECT_ID = IMM.ID
                                                                                                                                                                                                                                        AND IMM.ID = ODF.ID
                                                                                                                                                                                                                                        AND PK_ID = TSK.PRID
                                                                                                                                                                                                                                        AND prprojectid = srm_projects.id ), 0) + NVL(( SELECT NVL(ITL_GET_ACTUAL_EFFORT_FCT(OBJECT_ID), 0)
                                                                                                                                                                                                                                                                                        FROM ITL_OBJECT_ASSOCIATIONS Assoc,
                                                                                                                                                                                                                                                                                             IMM_INCIDENTS IMM,
                                                                                                                                                                                                                                                                                             ODF_CA_INCIDENT ODF,
                                                                                                                                                                                                                                                                                             PRTASK TSK
                                                                                                                                                                                                                                                                                          WHERE Assoc.OBJECT_ID = IMM.ID
                                                                                                                                                                                                                                                                                                  AND IMM.ID = ODF.ID
                                                                                                                                                                                                                                                                                                  AND PK_ID = TSK.PRID
                                                                                                                                                                                                                                                                                                  AND prprojectid IN ( SELECT id
                                                                                                                                                                                                                                                                                                                       FROM BHI_SubDep_Parent_v
                                                                                                                                                                                                                                                                                                                         WHERE parent_id = srm_projects.id ) ), 0)) actuals,
                           (NVL(( SELECT NVL(estsum, 0)
                                  FROM prj_project_estsum_v
                                    WHERE id = srm_projects.id ), 0) + NVL(( SELECT SUM(NVL(estsum, 0))
                                                                             FROM prj_project_estsum_v act,
                                                                                  BHI_SubDep_Parent_v ppv
                                                                               WHERE act.id = ppv.id
                                                                                       AND ppv.parent_id = srm_projects.id ), 0) + NVL(( SELECT SUM(NVL(estsum, 0))
                                                                                                                                         FROM prj_project_estsum_v act,
                                                                                                                                              BHI_SubDep_Parent_v ppv
                                                                                                                                           WHERE act.id = ppv.id
                                                                                                                                                   AND ppv.parent_id IN ( SELECT id
                                                                                                                                                                          FROM BHI_SubDep_Parent_v
                                                                                                                                                                            WHERE parent_id = srm_projects.id ) ), 0)) etc
                    FROM odf_ca_project ,
                         PRJ_PROJECTS ,
                         SRM_PROJECTS ,
                         PRJ_PROJECTS PR1
                           LEFT JOIN PRJ_BASELINE_DETAILS BASEREC
                            ON ( BASEREC.BASELINE_ID = PR1.BASELINE_ID
                           AND BASEREC.OBJECT_TYPE = 'PROJECT' )
                      WHERE srm_projects.id = prj_projects.prid
                              AND srm_projects.id = odf_ca_project.id
                              AND SRM_PROJECTS.ID = PR1.PRID
                              AND srm_projects.id IN ( SELECT id
                                                       FROM BHI_SubDep_Parent_v
                                                         WHERE parent_id =v_prjid )
                    UNION
                    SELECT 2 projsub,
                          v_prjid PID,
                           assoc.id prj_id,
                           NULL SubProjCount,
                           NVL(BHI_hcc_ticket_no, '') Unique_name,
                           imm.SUBJECT prj_name,
                           NULL baseline,
                           (NVL(( SELECT SUM(NVL(actuals, 0))
                                  FROM BHI_PROJECT_BaselineActualsETC
                                    WHERE PID = ( SELECT id
                                                  FROM srm_projects
                                                    WHERE unique_name = odf.bhi_bot_bas_proj ) ), 0) + NVL(ITL_GET_ACTUAL_EFFORT_FCT(OBJECT_ID), 0)) Actuals,
                           NULL etc
                    FROM ITL_OBJECT_ASSOCIATIONS Assoc,
                         IMM_INCIDENTS IMM,
                         ODF_CA_INCIDENT ODF,
                         PRTASK TSK
                      WHERE Assoc.OBJECT_ID = IMM.ID
                              AND IMM.ID = ODF.ID
                              AND PK_ID = TSK.PRID
                              AND prprojectid =v_prjid ) prj_sum
             UNION
             SELECT 2 projsub,
                   v_prjid PID,
                    assoc.id prj_id,
                    NULL SubProjCount,
                    NVL(BHI_hcc_ticket_no, '') Unique_name,
                    imm.SUBJECT prj_name,
                    NULL baseline,
                    (NVL(( SELECT SUM(NVL(actuals, 0))
                           FROM BHI_PROJECT_BaselineActualsETC
                             WHERE PID = ( SELECT id
                                           FROM srm_projects
                                             WHERE unique_name = odf.bhi_bot_bas_proj ) ), 0) + NVL(ITL_GET_ACTUAL_EFFORT_FCT(OBJECT_ID), 0)) Actuals,
                    NULL etc
             FROM ITL_OBJECT_ASSOCIATIONS Assoc,
                  IMM_INCIDENTS IMM,
                  ODF_CA_INCIDENT ODF
               WHERE Assoc.OBJECT_ID = IMM.ID
                       AND IMM.ID = ODF.ID
                       AND Assoc.pk_id =v_prjid );

         --PRINT @PRJID
       
         
       DBMS_OUTPUT.PUT_LINE( to_char(systimestamp, 'HH24:MI:SS.FF6') || '  :  ' || to_char(v_prjid));
         
         
     
   END LOOP;
  CLOSE c1;
 

 
 

END;



 
  EXCEPTION
    WHEN OTHERS THEN

  DBMS_OUTPUT.PUT_LINE(SQLERRM);




END;


Start Free Trial
[+][-]06.18.2008 at 05:30PM PDT, ID: 21818404

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.

 
[+][-]06.18.2008 at 05:32PM PDT, ID: 21818418

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.

 
[+][-]06.18.2008 at 05:39PM PDT, ID: 21818436

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.

 
[+][-]06.18.2008 at 05:49PM PDT, ID: 21818470

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.

 
[+][-]06.18.2008 at 08:45PM PDT, ID: 21819058

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.

 
[+][-]06.18.2008 at 08:50PM PDT, ID: 21819078

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.

 
[+][-]06.18.2008 at 09:03PM PDT, ID: 21819117

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.

 
[+][-]06.19.2008 at 07:06AM PDT, ID: 21822237

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.

 
[+][-]06.19.2008 at 09:27AM PDT, ID: 21823826

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.

 
[+][-]06.19.2008 at 09:31AM PDT, ID: 21823870

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

Zones: Oracle 10.x, Oracle 9.x, PL / SQL
Tags: Oracle, Oracle 10g, 10g, cursor insert hanging, SQL
Sign Up Now!
Solution Provided By: sdstuber
Participating Experts: 1
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628