0

我尝试通过 apex online 运行以下代码

 DECLARE
    t1 VARCHAR(44);
    t2 VARCHAR(11);
    c VARCHAR(3);
    BEGIN
    t1:='061,065,059,067,064,066,071,111,110,121,077.';
    t2:=NULL;
    FOR I IN LENGTH(t1)/4
     loop
    c:=SUBSTR(t1,((LENGTH(t1)/4),3);
    t2:=t2||CHR(TO_NUMBER(c));

    end loop;
    DBMS_OUTPUT.PUT_LINE(t2);
    END;

但是出现以下错误

ORA-06550: line 9, column 2:
PLS-00103: Encountered the symbol "LOOP" when expecting one of the following:

   * & - + / at mod remainder rem .. <an exponent (**)> ||

谢谢大家,我解决了第二个错误,实际上

c:=SUBSTR(s1,1+((LENGTH(s1)/4)-I)*4,3);
4

2 回答 2

1
FOR I IN 1..LENGTH(t1)/4 LOOP

END LOOP;
于 2013-02-07T20:46:03.697 回答
0

试试这个:

DECLARE
    t1 VARCHAR(50);
    t2 VARCHAR(100);
    c VARCHAR(50);
BEGIN
    t1:='061,065,059,607,064,066,071,111,110,121,077.';
    t2:=NULL;
    FOR I IN 1..LENGTH(t1)/4 loop
       c:=SUBSTR(t1,(LENGTH(t1)/4),3);
   --  t2:=t2||CHR(TO_NUMBER(c));
       t2:=t2||(c);
    end loop;
    DBMS_OUTPUT.PUT_LINE(t2);
END;
于 2013-02-08T04:49:11.060 回答