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

  • Home
  • SEARCH
  • 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 7091741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:13:32+00:00 2026-05-28T08:13:32+00:00

Trying to use records with the cursor and later index by table in the

  • 0

Trying to use records with the cursor and later index by table in the mix.

DECLARE CURSOR emp_cur IS
    SELECT employee_id, first_name||' '|| last_name "name"
    FROM employees 
    ORDER BY salary desc;

emp_rec emp_cur%ROWTYPE;

BEGIN 
    FOR emp_rec IN emp_cur
    LOOP
        DBMS_OUTPUT.PUT_LINE('Employee ID:'||emp_rec.employee_id||CHR(10)||
                             'Employee Name:'||emp_rec.name);
        EXIT WHEN emp_cur%ROWCOUNT = 10;
    END LOOP;
END;

When I run above code I get

 ERROR at line 13, "NAME" must be declared.

How can I access the column first_name||’ ‘||last_name inside the For loop? or do I just have to do traditional OPEN, simple loop, FETCH and close?

  • 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-28T08:13:33+00:00Added an answer on May 28, 2026 at 8:13 am

    You’re very close; the problem is just that identifiers that are not in double-quotes get converted to uppercase, while identifiers that are in double-quotes do not. So name, NAME, and "NAME" are equivalent to each other, and all of them are different from "name". Either change this:

    first_name||' '|| last_name "name"
    

    to this:

    first_name||' '|| last_name name
    

    or else, if you prefer, change this:

    'Employee Name:'||emp_rec.name
    

    to this:

    'Employee Name:'||emp_rec."name"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to fetch some records from table but when i use OR
I am trying to use the following query on a table with ~200k records
I'm new to PL/SQL and I'm trying to use a table of records, but
I'm trying to use saveAll correctly to update User records for multiple relational models.
I'm trying to use a ListAdapter to display the results of a Cursor. According
I'm trying to use a script to process a lot of dta records, let's
I'm trying to use the below code to bring back all records that are
I'm trying to use a trigger function to update old records in the same
I'm trying to use the following awk script to count every 1000 records from
I am looking on trying to use acts_as_paranoid plugin for soft delete of records.

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.