这是我的代码,我觉得这ORACLE这点都不能达到,有点搞笑了
set serveroutput on size 1000000;
declare
strdbcursor1 varchar2(50);
cursor dbcursor1 is select 表编码 from testmis.zbm_dict,testmis.zfl_dict
where 保密级别>1 and testmis.zbm_dict.分类编码=testmis.zfl_dict.分类编码
and testmis.zfl_dict.数据库编码='FXHY';
begin
delete testmis.temp;
open dbcursor1;
fetch dbcursor1 into strdbcursor1;
while dbcursor1%found
loop /* 读取表字段 */
declare
strdbcursor2 varchar(50);
cursor dbcursor2(strp varchar2) is select COLUMN_NAME from user_col_comments where upper(TABLE_NAME)=upper(strp);
strTemp varchar2(500);
begin
strTemp:='';
open dbcursor2(strdbcursor1);
fetch dbcursor2 into strdbcursor2;
while dbcursor2%found loop
if strTemp is null then
strTemp:='convert(varchar,'||strdbcursor2||')';
else
strTemp:='('||strTemp||','||strdbcursor2||'); /*'('||strTemp||','||strdbcursor2||')';*/
end if;
fetch dbcursor2 into strdbcursor2;
end loop;
close dbcursor2;
insert into testmis.temp (context) values (strTemp);
end;
fetch dbcursor1 into strdbcursor1;
end loop;
close dbcursor1;
end;
set serveroutput on size 1000000;
declare
strdbcursor1 varchar2(50);
cursor dbcursor1 is select 表编码 from testmis.zbm_dict,testmis.zfl_dict
where 保密级别>1 and testmis.zbm_dict.分类编码=testmis.zfl_dict.分类编码
and testmis.zfl_dict.数据库编码='FXHY';
begin
delete testmis.temp;
open dbcursor1;
fetch dbcursor1 into strdbcursor1;
while dbcursor1%found
loop /* 读取表字段 */
declare
strdbcursor2 varchar(50);
cursor dbcursor2(strp varchar2) is select COLUMN_NAME from user_col_comments where upper(TABLE_NAME)=upper(strp);
strTemp varchar2(500);
begin
strTemp:='';
open dbcursor2(strdbcursor1);
fetch dbcursor2 into strdbcursor2;
while dbcursor2%found loop
if strTemp is null then
strTemp:='convert(varchar,'||strdbcursor2||')';
else
strTemp:='('||strTemp||','||strdbcursor2||'); /*'('||strTemp||','||strdbcursor2||')';*/
end if;
fetch dbcursor2 into strdbcursor2;
end loop;
close dbcursor2;
insert into testmis.temp (context) values (strTemp);
end;
fetch dbcursor1 into strdbcursor1;
end loop;
close dbcursor1;
end;
strTemp varchar2(500); strTemp:=strTemp||strdbcursor2;
strTemp:='('||strTemp||','||')';
strTemp:=strTemp||'1234'; strTemp:=strTemp||','||strdbcursor2;
strTemp:=strTemp||'12345';
strTemp:='('||strTemp||','||strdbcursor2||'); <--这里最后似乎少了一个单引号 别的没看出有什么错误, 编译一下,看看错误内容.
谢谢...
1 declare
2 strdbcursor1 varchar2(50);
3 cursor dbcursor1 is select 表编码 from testmis.zbm_dict,testmis.zfl_dict
4 where 保密级别>1 and testmis.zbm_dict.分类编码=testmis.zfl_dict.分类编码
5 and testmis.zfl_dict.数据库编码='FXHY';
6 begin
7 delete testmis.temp;
8 open dbcursor1;
9 fetch dbcursor1 into strdbcursor1;
10 while dbcursor1%found
11 loop /* 读取表字段 */
12 declare
13 strdbcursor2 varchar(50);
14 cursor dbcursor2(strp varchar2) is select COLUMN_NAME from user_col_comments where
15
16 upper(TABLE_NAME)=upper(strp);
17 strTemp varchar2(500);
18 begin
19 strTemp:='';
20 open dbcursor2(strdbcursor1);
21 fetch dbcursor2 into strdbcursor2;
22 while dbcursor2%found loop
23
24 if strTemp is null then
25 strTemp:='convert(varchar,'||strdbcursor2||')';
26 else
27 strTemp:='('||strTemp||','||strdbcursor2||')';
28 end if;
29
30
31 fetch dbcursor2 into strdbcursor2;
32 end loop;
33 close dbcursor2;
34 insert into testmis.temp (context) values (strTemp);
35 end;
36
37 fetch dbcursor1 into strdbcursor1;
38 end loop;
39 close dbcursor1;
40 end;
41*
41*
declare
*
ERROR 位于第 1 行:
ORA-06502: PL/SQL: 数字或值错误
ORA-06512: 在line 27
strTemp:='('||strTemp||','||strdbcursor2||')';
改为
strTemp:='('''||strTemp||''','''||strdbcursor2||''')';