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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:23:14+00:00 2026-06-14T18:23:14+00:00

Why doesn’t my dynamic sql procedure work? All I’m trying to do is show

  • 0

Why doesn’t my dynamic sql procedure work? All I’m trying to do is show a simple column from a table. I get the following erros:

ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00905: object SYSTEM.JOIN is invalid
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

 create or replace procedure join
(p_table1 in varchar2,
p_joincolumn1 in varchar2,
p_joincolumn2 in varchar2)
 AS
lv_query varchar2(500);
lv_cursor number;
lv_col1 VARCHAR2(30);
lv_col2 VARCHAR2(30);
loopcount number:=0;
cursor_return_value integer;
 begin
lv_cursor:=dbms_sql.open_cursor;
dbms_output.put_line('Value assigned to cursor= ' || lv_cursor );
lv_query:='select p_joincolumn1 from p_table1';
dbms_output.put_line(lv_query);
dbms_sql.parse(lv_cursor, lv_query, dbms_sql.native);
dbms_sql.define_column (lv_cursor, 1, lv_col1);
dbms_sql.define_column (lv_cursor, 2, lv_col2);
cursor_return_value := dbms_sql.execute (lv_cursor);
LOOP
    loopcount:=loopcount+1;
    dbms_output.put_line('loopcount= ' || loopcount );
    if dbms_sql.fetch_rows (lv_cursor)=0 then
        EXIT;
    end if;

    dbms_sql.column_value(lv_cursor, 1, lv_col1);
    dbms_sql.column_value (lv_cursor, 2, lv_col2);
    dbms_output.put_line(lv_col1 || '   ' || lv_col2 ); 
END LOOP;
 dbms_output.put_line('At end of loop');
 dbms_sql.close_cursor(lv_cursor);
 end;
 /

 execute join ('PROJECT', 'PROJECT.P_ID', 'PROJECT.SKILL_ID');

Errors:

 Procedure created.

 SQL> 
 SQL> execute testing_j ('PROJECT', 'PROJECT.P_ID', 'PROJECT.SKILL_ID');
 Value assigned to cursor= 20
 select p_joincolumn1 from p_table1
 BEGIN testing_j ('PROJECT', 'PROJECT.P_ID', 'PROJECT.SKILL_ID'); END;

 *
 ERROR at line 1:
 ORA-00942: table or view does not exist
 ORA-06512: at "SYS.DBMS_SYS_SQL", line 906
 ORA-06512: at "SYS.DBMS_SQL", line 39
 ORA-06512: at "SYSTEM.TESTING_J", line 17
  • 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-14T18:23:16+00:00Added an answer on June 14, 2026 at 6:23 pm

    Fixed my code, and it works now. Changed dbms_sql.native to dbms_sql.v7, and also changed some syntax.

    create or replace procedure testing_j
    (table_name in varchar2,
    column1 in varchar2)
    AS
    lv_query varchar2(500);
    lv_cursor number;
    lv_col1 number(6);
    loopcount number:=0;
    cursor_return_value integer;
    begin
    lv_cursor:=dbms_sql.open_cursor;
    dbms_output.put_line('Value assigned to cursor= ' || to_char(lv_cursor));
    lv_query:='SELECT ' || column1 || ' FROM ' || table_name;
    dbms_output.put_line(lv_query);
    dbms_sql.parse(lv_cursor, lv_query, dbms_sql.v7);
    
    
    
    dbms_sql.define_column (lv_cursor, 1, lv_col1);
    cursor_return_value := dbms_sql.execute (lv_cursor);
    LOOP
        loopcount:=loopcount+1;
        --dbms_output.put_line('loopcount= ' || loopcount );
        if dbms_sql.fetch_rows (lv_cursor)=0 then
            EXIT;
        end if;
    
        dbms_sql.column_value(lv_cursor, 1, lv_col1);
        dbms_output.put_line(lv_col1);  
    END LOOP;
    dbms_output.put_line('At end of loop');
    dbms_sql.close_cursor(lv_cursor);
    end;
    /
    
    
    PL/SQL procedure successfully completed.
    
    SQL> execute testing_j ('PROJECT', 'PROJECT.P_ID');
    Value assigned to cursor= 12
    SELECT PROJECT.P_ID FROM PROJECT
    1
    1
    2
    3
    3
    4
    4
    5
    5
    6
    7
    7
    At end of loop
    
    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

This doesn't work: int number = 1; String numberstring = IntToString(number); I get The
This doesn't work: $to = 'myemail@gmail.com'; $from = 'test@test.com'; $subj = 'test'; $message =
Why doesn't the following work? It appears that the literal zero at the end
Doesn't seem to work for me, maybe I just doing it wrong
Doesn't the space occupied by a variable get deallocated as soon as the control
Why doesn't this code work? b if b = true Error: undefined local variable
Why doesn't this work? Some Usercontrol (name: myUserControl) with an image control (name: myImage):
Why doesn't this test case work? <?php // cards with cyrillic inidices and suits
Doesn't matter what I do, I simply can't get this to play a sound
Why doesn't this work? type RetryBuilder(max) = member x.Return(a) = a // Enable 'return'

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.