这是我的代码,我觉得这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;

解决方案 »

  1.   

    我试的是这个代码:strdbcursor2 varchar(50);
    strTemp varchar2(500); strTemp:=strTemp||strdbcursor2; 
     strTemp:='('||strTemp||','||')';
     strTemp:=strTemp||'1234'; strTemp:=strTemp||','||strdbcursor2; 
     strTemp:=strTemp||'12345';
      

  2.   

    strTemp:='('  ¦  ¦strTemp  ¦  ¦','  ¦  ¦strdbcursor2  ¦¦')'; --少了单引号
      

  3.   

    else
       strTemp:='('||strTemp||','||strdbcursor2||');   <--这里最后似乎少了一个单引号 别的没看出有什么错误, 编译一下,看看错误内容.
      

  4.   

    呵呵,,,bzszp(SongZip)兄 比我看的快.
      

  5.   

    多谢大家,不过还是没说道点上,少单引号是我贴上时弄错的,我现在给出全部内容,及错误提示
    谢谢...
     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
      

  6.   

    这一行
    strTemp:='('||strTemp||','||strdbcursor2||')';
    改为
    strTemp:='('''||strTemp||''','''||strdbcursor2||''')';
      

  7.   

    可能是 varchar 和 varchar2 的問題.請將 strdbcursor2 varchar(50) 改為 strdbcursor2 varchar2(50)試試.