Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8453237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:43:03+00:00 2026-06-10T11:43:03+00:00

Please can you assist me if possible, i need to optimize the below block

  • 0

Please can you assist me if possible, i need to optimize the below block of code if order to iterate the values quicker. see below statement :

for CONSULTANT_RECORD IN CONSULTANT_CURSOR LOOP /*Loop 2*/
VData := VData||crlf2||CONSULTANT_RECORD.USER_FIRSTNAME||'   '||CONSULTANT_RECORD.USER_SURNAME;

vTOT_LOG_CLOSED4USER := 0;
vAVERAGE_DAY := 0;
vTOT_DAYS := 0;
for x in 1..vlastday loop /*Loop 3*/
  select COUNT(DISTINCT LOG_NO) as "LOG_COUNT" INTO vLOG_COUNTER
    FROM DMS_CRM.TBL_DMS_SERVICE_REQUESTS_HIST
      WHERE LOG_STATUS = 'Resolved'
       AND TO_CHAR(HIST_DATE_TIME_STAMP, 'MONTH,YYYY') = TO_CHAR(SYSDATE, 'MONTH,YYYY')
       AND TO_CHAR(HIST_DATE_TIME_STAMP, 'DD') = lpad(to_char(x),2,'0')
       AND OWNER_USER_ID IS NOT NULL
       AND OWNER_USER_ID = CONSULTANT_RECORD.OWNER_USER_ID;

    end loop;
END LOOP;

The problem starts happening in the Comment Loop 3, bare in mind im developing over oracle app portal, so i cant run query optimization… my tables are indexed correctly as well (if anyone wants to comment on it).

Regards,

PS. No one has gotten back to me with their version of the code……….i am still struggling with this 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T11:43:04+00:00Added an answer on June 10, 2026 at 11:43 am

    I think the best loop is no loop at all (surely, if it’s can be avoided). Assuming vlastday is a collection, you can do something like

    select COUNT(DISTINCT LOG_NO) as "LOG_COUNT" 
    FROM DMS_CRM.TBL_DMS_SERVICE_REQUESTS_HIST
    INNER JOIN 
      (
        SELECT lpad(to_char(t.COLUMN_VALUE ),2,'0') as x 
        from table(vlastday)t
      )a ON (TO_CHAR(HIST_DATE_TIME_STAMP, 'DD') = a.x)
      WHERE LOG_STATUS = 'Resolved'
       AND TO_CHAR(HIST_DATE_TIME_STAMP, 'MONTH,YYYY') = TO_CHAR(SYSDATE, 'MONTH,YYYY')       
       AND OWNER_USER_ID IS NOT NULL
       AND OWNER_USER_ID = CONSULTANT_RECORD.OWNER_USER_ID
       GROUP BY a.x;
    

    Then depends on your task, you need to either get rid of GROUP BY so you can select into, or declare a collection of numbers and BULK COLLECT into this variable.

    Also, I from what I see in the question, you can do pretty much the same for Loop2 so you won’t have loops …

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please can someone help? I have the following code which uploads a file to
Can someone please assist me. I am trying to find a log on an
Can anyone please tell me what is the main use of visual assist? Does
Can someone please assist me on why my background color of the frame is
I hope someone can assist me please. I am using a pullout widget in
Please can some one explain the javacv method for the pyrDown() method. I'm trying
Please can some one give an example describing cascading as meant in CSS and
please can anyone tell me how to validate a text box while iam moving
Please can you suggest me an example in classic asp and ajax to make
Please can anyone one point me to a good tutorial that helps me to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.