Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to bind a table name in dynamic sql

567173Jun 25 2007 — edited Jun 26 2007
I wanna bind a table name into a dynamic statement

create or replace procedure test_pack(amount out number)
as
cursor_name INTEGER;
v_Err_No Number;
v_Err_Descr Varchar2(256);
begin
cursor_name := dbms_sql.open_cursor;
dbms_sql.parse(cursor_name, 'delete from :t', dbms_sql.native);
dbms_sql.bind_variable(cursor_name, ':t', 'tt');
amount:=dbms_sql.execute(cursor_name);
dbms_sql.close_cursor(cursor_name);
exception
when others then
v_Err_No := Sqlcode;
v_Err_Descr := Substr(Sqlerrm, 1, 250);
Dbms_Output.Put_Line('ERROR:' || v_Err_No || ':' || v_Err_Descr);
dbms_sql.close_cursor(cursor_name);
end;

But I always get "invalid table name"

But actually,
SQL> select count(*) from tt;

COUNT(*)
----------
1

SQL>

Why?

thanks,
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 24 2007
Added on Jun 25 2007
8 comments
6,379 views