如何使用获取表复制表的名称和新表的名称的过程来复制表,以在PL/SQL Oracle中创建它?
运行以下代码,
create or replace procedure copy_table(
from_table in out varchar2,
new_table_name in out varchar2
) is v varchar(4000);
begin
v :='create table new_table_name as select * from from_table';
execute immediate v;
end copy_table;
begin
copy_table(lalala, new_table);
end;
我收到错误
begin
copy_table(lalala, new_table);
end;
Error report -
ORA-06550: line 2, column 12:
PLS-00357: Table,View Or Sequence reference 'LALALA' not allowed in this context
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
如何正确调用该过程,因为我有“ Lalala”表? 我的程序可以用于应对现有表并创建新表格吗?还是代码错误?
Running the following code
create or replace procedure copy_table(
from_table in out varchar2,
new_table_name in out varchar2
) is v varchar(4000);
begin
v :='create table new_table_name as select * from from_table';
execute immediate v;
end copy_table;
begin
copy_table(lalala, new_table);
end;
I got the error
begin
copy_table(lalala, new_table);
end;
Error report -
ORA-06550: line 2, column 12:
PLS-00357: Table,View Or Sequence reference 'LALALA' not allowed in this context
ORA-06550: line 2, column 1:
PL/SQL: Statement ignored
How to correctly call the procedure since I alredy have "lalala" table?
And will my procedure work for coping the existing table and create a new one? Or the code is wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您已经将过程参数作为字符串传递,而它们必须作为变量传递。此外,您的过程参数必须仅在外而不是输入。因此,您的更新代码将是 -
You have passed the procedure parameters as strings while they must be passed as variables. Also your procedure parameters must be IN only instead of IN OUT. So your updated code would be -
Demo.