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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:21:11+00:00 2026-06-16T17:21:11+00:00

I am trying to dynamically resolve the value from cursor something like below. create

  • 0

I am trying to dynamically resolve the value from cursor something like below.

create or replace
PROCEDURE test(
PI_JANUS_ID IN VARCHAR2,
PO_dummy out Types.CursorType
)AS
PO_ACTUALCUROSR Types.CursorType;
cur_row tab%ROWTYPE;
val1 varchar2(100);
val2 varchar2(200);
BEGIN
 open PO_ACTUALCUROSR for select * from tab;

  LOOP
    FETCH PO_ACTUALCUROSR into cur_row;
    EXIT WHEN PO_ACTUALCUROSR%NOTFOUND;
    val1 := 'TNAME';
    SELECT 'cur_row.'||val1 INTO val2 FROM DUAL;
    dbms_output.put_line('Column Value ' || val2); 
  END LOOP ;
  CLOSE PO_ACTUALCUROSR;
END;

Here if you see I have to call cur_row. to get the value but here I have the column name in a variable (val1). So how will I take the value from the cursor.

If I execute the above block I would see “cur_row.TNAME” but I actually need the value in the cursor.

Is there a way of doing this.

Any help is very much appreciated.

  • 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-16T17:21:13+00:00Added an answer on June 16, 2026 at 5:21 pm

    just do

    BEGIN
     open PO_ACTUALCUROSR for select * from tab;
    
      LOOP
        FETCH PO_ACTUALCUROSR into cur_row;
        EXIT WHEN PO_ACTUALCUROSR%NOTFOUND;
        val2 := cur_row.tname;
        dbms_output.put_line(val2);
      END LOOP ;
      CLOSE PO_ACTUALCUROSR;
    end;
    

    or

    dbms_output.put_line(cur_row.tname);
    

    directly will also work.

    p.s. your variable

    val2 varchar2(200);
    

    is better as

    val2 tab.tname%type;
    

    if you’re saying you need to dynamically pull columns without knowing the column name ahead of time you’d have to use dynamic sql, and as you’re using a pl/sql array, we need to put that in a package spec so that we can reference it (as you cannot pass pl/sql only types into dynamic SQL).

    SQL> create table tab(id number, col1 varchar2(10));
    
    Table created.
    
    SQL> insert into tab values (1, 'a');
    
    1 row created.
    
    SQL> commit;
    
    Commit complete.
    
    SQL> create package global_var
      2  as
      3    cur_row tab%rowtype;
      4  end;
      5  /
    
    Package created.
    
    SQL> declare
      2  po_actualcurosr sys_refcursor;
      3  val1 varchar2(10) := 'COL1';
      4  val2 tab.col1%type;
      5  begin
      6   open po_actualcurosr for select * from tab;
      7
      8     loop
      9             fetch po_actualcurosr into global_var.cur_row;
     10             exit when po_actualcurosr%notfound;
     11             execute immediate 'begin :a := global_var.cur_row.'||dbms_assert.simple_sql_name(val1)||'; end;' using out val2;
     12             dbms_output.put_line(val2);
     13     end loop ;
     14     close po_actualcurosr;
     15  end;
     16  /
    a
    
    PL/SQL procedure successfully completed.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to dynamically form a nested tree object something like below using
I'm trying to dynamically create a navbar from data i fetch from a web
I'm trying to dynamically create a link from a Windows Form to our website
I'm trying to test if urls dynamically passed to image tags would resolve or
I'm trying to dynamically create and remove items from a list, it works just
Trying to dynamically change dropdown list values from mysql database. Script seems like workin
I'm trying to figure out how to resolve relatively referenced resources inside dynamically loaded
I'm trying to dynamically create alert messages using the jQuery plugin for Bootstrap CSS.
I'm currently trying dynamically create an html table in PHP. Further, I want the
I'm trying to dynamically delete elements from an array in bash based on a

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.