Sign Up

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

Have an account? Sign In
Continue with Google
or use


Have an account? Sign In Now

Sign In

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

Sign Up Here
Continue with Google
or use

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.

Continue with Google
or use

Forgot Password?

Need An Account, Sign Up Here

Sorry, you do not have permission to add post.

Continue with Google
or use

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.

Oraask Logo Oraask Logo
Sign InSign Up

Oraask

  • Write
    • Add A New Post
    • Ask A Question

Oraask Navigation

Search
Ask A Question

Mobile menu

Close
Ask A Question
  • Categories
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Dev Tools
    • Online Compiler
    • Base64 Converter
    • Oraask XML Formatter
    • Oraask JSON Formatter
  • Wiki
    • SQL Tutorials
    • Java Tutorials
    • Python Tutorials
    • JavaScript Tutorials
Home/ Questions/Q 79788
Next
Answered

Oraask Latest Questions

Question
Olivier
  • 0
  • 0
OlivierExplorer
Asked: July 7, 20222022-07-07T02:30:00+03:00 2022-07-07T02:30:00+03:00In: Oracle SQL

Why do we use bulk collect in Oracle

  • 0
  • 0

I need somebody to explain briefly why do we use bulk collect in Oracle

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

    Related Questions

    • How to get Column Names from a Table in Oracle
    • What are the different types of case manipulation functions available in Oracle SQL
    • What is the use of ADD, DROP and MODIFY Commands
    • What are the differences between SQL and PL/SQL in Oracle
    • What is the use of LIMIT and OFFSET in SQL

    1 Answer

    • Voted
    • Oldest
    • Recent
    1. Hassan AbdElrahman
      Best Answer
      Hassan AbdElrahman Master Oracle ACE Pro Alum ♠ | Oracle Senior ERP Technical Consultant
      2022-07-08T20:51:04+03:00Added an answer on July 8, 2022 at 8:51 pm

      BULK COLLECT in Oracle PL/SQL:

      BULK COLLECT in Oracle PL/SQL reduces the round trip between SQL engine and PL/SQL engine and allows SQL engine to fitch a bulk collection of data at once instead of the traditional LOOP statement.

      We are using the BULK COLLECT clause in the SELECT statement to fitch the cursor result set in bulk or to populate the records in bulk.

      Since the BULK COLLECT fetches a result set or more than one record, the INTO clause must contain a collection variable like Oracle TYPE.

      Example:

      DECLARE
      CURSOR oraask_dept_details
      IS
      SELECT * FROM departments;

      TYPE l_dept_details_tbl IS TABLE OF departments%ROWTYPE;

      l_dept_details l_dept_details_tbl;
      BEGIN
      OPEN oraask_dept_details;

      LOOP
      FETCH oraask_dept_details BULK COLLECT INTO l_dept_details LIMIT 10;

      EXIT WHEN l_dept_details.count = 0;

      FOR dept_details_rec IN l_dept_details.first .. l_dept_details.last
      LOOP
      dbms_output.put_line ('DEPARTMENT ID:' || l_dept_details (dept_details_rec).department_id || ' - DEPARTMENT NAME:' || l_dept_details (dept_details_rec).department_name);
      END LOOP;
      END LOOP;

      CLOSE oraask_dept_details;
      END;
      /

      Output :

      DEPARTMENT ID:10 - DEPARTMENT NAME:Administration
      DEPARTMENT ID:20 - DEPARTMENT NAME:Marketing
      DEPARTMENT ID:30 - DEPARTMENT NAME:Purchasing
      DEPARTMENT ID:40 - DEPARTMENT NAME:Human Resources
      DEPARTMENT ID:50 - DEPARTMENT NAME:Shipping
      DEPARTMENT ID:60 - DEPARTMENT NAME:IT
      DEPARTMENT ID:70 - DEPARTMENT NAME:Public Relations
      DEPARTMENT ID:80 - DEPARTMENT NAME:Sales
      DEPARTMENT ID:90 - DEPARTMENT NAME:Executive
      DEPARTMENT ID:100 - DEPARTMENT NAME:Finance
      DEPARTMENT ID:110 - DEPARTMENT NAME:Accounting
      DEPARTMENT ID:120 - DEPARTMENT NAME:Treasury
      DEPARTMENT ID:130 - DEPARTMENT NAME:Corporate Tax
      DEPARTMENT ID:140 - DEPARTMENT NAME:Control And Credit
      DEPARTMENT ID:150 - DEPARTMENT NAME:Shareholder Services
      DEPARTMENT ID:160 - DEPARTMENT NAME:Benefits
      DEPARTMENT ID:170 - DEPARTMENT NAME:Manufacturing
      DEPARTMENT ID:180 - DEPARTMENT NAME:Construction
      DEPARTMENT ID:190 - DEPARTMENT NAME:Contracting
      DEPARTMENT ID:200 - DEPARTMENT NAME:Operations
      DEPARTMENT ID:210 - DEPARTMENT NAME:IT Support
      DEPARTMENT ID:220 - DEPARTMENT NAME:NOC
      DEPARTMENT ID:230 - DEPARTMENT NAME:IT Helpdesk
      DEPARTMENT ID:240 - DEPARTMENT NAME:Government Sales
      DEPARTMENT ID:250 - DEPARTMENT NAME:Retail Sales
      DEPARTMENT ID:260 - DEPARTMENT NAME:Recruiting
      DEPARTMENT ID:270 - DEPARTMENT NAME:Payroll

      In the above script, we used a LIMIT clause to limit fetching the bulk of records to 10 records at a time. This clause is very handful when dealing with a large number of records to avoid running out of memory because the collection type we use is expanding as more records are inserted into it.

      Do you find it helpful? Share to spread the knowledge

        • 1
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Continue with Google
    or use

    Forgot Password?

    Need An Account, Sign Up Here
    Continue with Google

    Sidebar

    Adv 250x250

    Explore

    • Categories
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Dev Tools
      • Online Compiler
      • Base64 Converter
      • Oraask XML Formatter
      • Oraask JSON Formatter
    • Wiki
      • SQL Tutorials
      • Java Tutorials
      • Python Tutorials
      • JavaScript Tutorials

    Footer

    Oraask

    About

    Oraask is a website for developers and software engineers who want to learn new skills, share their knowledge, and solve their coding problems. Oraask provides free content on various programming languages and topics, such as Oracle, Python, Java, etc. Oraask also allows users to ask questions and get answers from other members of the community.

    About Us

    • About Us
    • Contact Us

    Legal Stuff

    • Privacy Policy
    • Terms & Conditions

    Follow

    Oraask is licensed under CC BY-NC-SA 4.0Oraask CopyrightOraask CopyrightOraask CopyrightOraask Copyright

    © 2019 Oraask. All Rights Reserved
    With Love by Oraask.

    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.