'drop table newtable; create table newtable for select
field1, field2 from oldtable' 改为:
'drop table newtable; create table newtable select
field1, field2 from oldtable'
field1, field2 from oldtable' 改为:
'drop table newtable; create table newtable select
field1, field2 from oldtable'
直接在文本编辑器中编辑好两句,
drop table newtable;
create table newtable as select field1,field2 from oldtable;
存入c:\test.sql文件中,
在sqlplus下:@c:\test.sql
即可执行。
在这里 sql_str1 和 sql_str2 是存储过程的两参数 如果只用一个参数
:做为字符串,就要在过程里判断,截取不就行了?
sql_str:='drop table newtable; create table newtable for select
field1, field2 from oldtable'
sql_str1 := SUBSTR(sql_str,I,INSTR(sql_str,‘;’)。。
execute immediate sql_str1;
sql_str varchar2(100);
begin
sql_str:='begin drop table bb; drop table cc; end;';
execute immediate sql_str;
end;
/试试这种方式,来不及测试
---------------------------
Error
---------------------------
ORA-06550: 第 1 行, 第 7 列:
PLS-00103: 出现符号 "DROP"在需要下列之一时:
begin case declare exit
for goto if loop mod null pragma raise return select update
while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge
<a single-quoted SQL string> pipe
ORA-06512: 在"LD.TESTAAA", line 11
如果 sql_str 是 三条以上怎么办?
为一个 Clob 字段 实现安装软件的 表 及 存储过程 的创建 如果要通过你那种方法
可能要先在客户端实现生成 .sql 文本