ORA-06502 错误
DECLARE
RESULT VARCHAR2(255);
CURSOR cur_eq IS
SELECT column_name
FROM user_tab_columns
WHERE table_name = 'EQUIPMENT ';
v_col user_tab_columns.column_name%TYPE;
BEGIN
OPEN cur_eq;
LOOP
FETCH cur_eq
INTO v_col;
RESULT := RESULT || v_col || ', '; -- 这句编译出错
EXIT WHEN cur_eq%NOTFOUND;
END LOOP;
CLOSE cur_eq;
dbms_output.put_line(RESULT);
END;
------解决方案--------------------SQL> DECLARE
2 RESULT VARCHAR2(255);
3 CURSOR cur_eq IS
4 SELECT column_name
5 FROM user_tab_columns
6 WHERE table_name = 'T_SITE ';
7 v_col user_tab_columns.column_name%TYPE;
8 BEGIN
9 OPEN cur_eq;
10 LOOP
11 FETCH cur_eq
12 INTO v_col;
13 RESULT := RESULT || v_col || ', '; -- 这句编译出错
14 EXIT WHEN cur_eq%NOTFOUND;
15 END LOOP;
16 CLOSE cur_eq;
17 dbms_output.put_line(RESULT);
18 END;
19 /
UUID,SITETYPEID,NAME,CODE,TYPE,ADDRESS,PROPERTYRIGHTTYPE,XPOSITION,YPOSITION,SUBREGIONID,DMDZID,DMDZID,
PL/SQL procedure successfully completed
不是编译的错,估计是RESULT VARCHAR2(255);太小,超出长度了
------解决方案--------------------改成RESULT VARCHAR2(4000);