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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:16:16+00:00 2026-05-14T18:16:16+00:00

I am trying to use a strong ref cur with dynamic sql statment but

  • 0

I am trying to use a strong ref cur with dynamic sql statment but it is giving out an error,but when i use weak cursor it works,Please explain what is the reason and please
forward me any link of oracle server architect containing matter about how compilation and parsing is done in Oracle server. THIS is the error along with code.

ERROR at line 6:
ORA-06550: line 6, column 7:
PLS-00455: cursor 'EMP_REF_CUR' cannot be used in dynamic SQL OPEN statement
ORA-06550: line 6, column 2:
PL/SQL: Statement ignored

declare
      type ref_cur_type IS REF CURSOR RETURN employees%ROWTYPE; --Creating a strong REF cursor,employees is a table
     emp_ref_cur ref_cur_type;
     emp_rec employees%ROWTYPE;
BEGIN      
   OPEN emp_ref_cur FOR 'SELECT * FROM employees';
           LOOP
                   FETCH emp_ref_cur INTO emp_rec;
                   EXIT WHEN emp_ref_cur%NOTFOUND;
           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-14T18:16:17+00:00Added an answer on May 14, 2026 at 6:16 pm

    Here is a procedure with a strongly-typed ref cursor:

    SQL> create or replace procedure p1 is
      2      type dept_rc is ref cursor return dept%rowtype;
      3      my_ref_cursor dept_rc;
      4  begin
      5      open my_ref_cursor for
      6          select * from dept;
      7  end;
      8  /
    
    Procedure created.
    
    SQL>
    

    This next statement fails because the signature of the EMP record doesn’t match that of DEPT table.

    SQL> create or replace procedure p1 is
      2      type dept_rc is ref cursor return dept%rowtype;
      3      my_ref_cursor dept_rc;
      4  begin
      5      open my_ref_cursor for
      6          select * from emp;
      7  end;
      8  /
    
    Warning: Procedure created with compilation errors.
    
    SQL> show error
    Errors for PROCEDURE P1:
    
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    5/5      PL/SQL: SQL Statement ignored
    6/9      PLS-00382: expression is of wrong type
    
    SQL>
    

    But if we change the projection to match the DEPT table then we have success again:

    SQL> create or replace procedure p1 is
      2      type dept_rc is ref cursor return dept%rowtype;
      3      my_ref_cursor dept_rc;
      4  begin
      5      open my_ref_cursor for
      6          select deptno, ename, job from emp;
      7  end;
      8  /
    
    Procedure created.
    
    SQL>
    

    So, why can’t we use a strongly-typed ref-cursor with dynamic SQL?

    SQL> create or replace procedure p1 is
      2      type dept_rc is ref cursor return dept%rowtype;
      3      my_ref_cursor dept_rc;
      4  begin
      5      open my_ref_cursor for
      6          'select * from dept';
      7  end;
      8  /
    
    Warning: Procedure created with compilation errors.
    
    SQL> show error
    Errors for PROCEDURE P1:
    
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    5/5      PL/SQL: Statement ignored
    5/10     PLS-00455: cursor 'MY_REF_CURSOR' cannot be used in dynamic SQL
             OPEN statement
    
    SQL>
    

    Because the compiler cannot parse the string in the dynamic SQL statement. So it cannot assert that the columns in the query’s projection match in number and datatype the signature of the ref cursor. Consequently it cannot validate the contract between the ref cursor variable and the query. It is even easier to understand why this cannot be allowed when we consider that the dynamic SQL statement could be assembled from a query on USER_TAB_COLUMNS.

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

Sidebar

Ask A Question

Stats

  • Questions 408k
  • Answers 408k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You are almost there! The following two marks should do… May 15, 2026 at 6:43 am
  • Editorial Team
    Editorial Team added an answer You could follow Zend Framework standards like Option1 with autoload… May 15, 2026 at 6:43 am
  • Editorial Team
    Editorial Team added an answer If you need only IOCTL_MOUNTMGR_QUERY_POINTS definition it is following: #define… May 15, 2026 at 6:43 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.