How to bind a table name in dynamic sql
567173Jun 25 2007 — edited Jun 26 2007I 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,