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 7544931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:48:01+00:00 2026-05-30T08:48:01+00:00

How can you refer to a cursor’s specific value if there are multiple values

  • 0

How can you refer to a cursor’s specific value if there are multiple values returned?

DECLARE
  X INTEGER;
  CURSOR c1 IS SELECT col1, col2, col3.....;
BEGIN
  OPEN c1;
  LOOP
    EXIT WHEN c1%NOTFOUND;
    FETCH (col2 from c1) INTO X;
  END LOOP;
END;
  • 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-05-30T08:48:02+00:00Added an answer on May 30, 2026 at 8:48 am

    Why would you want to? Presumably, if you are selecting three columns in your cursor declaration, you need all three columns in your code, so you would need to fetch all three columns into three separate local variables, i.e.

    DECLARE
      x      integer;
      y      integer;
      z      integer;
      CURSOR c1
          IS SELECT column1, column2, column3
               FROM some_table;
    BEGIN
      OPEN c1;
      LOOP
        FETCH c1 
         INTO x, y, z;
        EXIT WHEN c1%NOTFOUND;
      END LOOP;
      CLOSE c1;
    END;
    

    Alternately, you can declare a record type based on the cursor declaration and fetch into that

    DECLARE
      CURSOR c1
          IS SELECT column1, column2, column3
               FROM some_table;
      c1_rec c1%ROWTYPE;
    BEGIN
      OPEN c1;
      LOOP
        FETCH c1 
         INTO c1_rec;
        dbms_output.put_line( c1_rec.column2 );
        EXIT WHEN c1%NOTFOUND;
      END LOOP;
      CLOSE c1;
    END;
    

    You can also get rid of the explicit loop entirely which is generally the preferred approach since you don’t have to worry about cursor leaks and (in modern versions) Oracle can automatically do bulk collects for you

    DECLARE
      CURSOR c1
          IS SELECT column1, column2, column3
               FROM some_table;
    BEGIN
      FOR c1_rec IN c1
      LOOP
        dbms_output.put_line( c1_rec.column2 );
      END LOOP;
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

You can refer to this post of mine. WebControl.Attributes.Add(string key, string value); This is
Is there some open source project I can refer to? I'm using PHP. Anyone
Is there any book/resource that one can refer to, to be able to write
I have multiple property files I need to refer to. Below I can refer
I have this class you see below in the answer. There I can refer
Is there any good example/tutorial sites where I can refer to regarding building website/web
I want to get an integer from a Cursor returned from a SQLite query,
In C# you can refer to values in a class using the 'this' keyword.
does anybody know any resources that I can refer to?
I would like to know how I can refer to a list item object

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.