varchar2(2000) 为什么内容长度只有1056多,剩余的就显示不了呢,实际内容2100使用语句:DECLARE
  SQLSTR  VARCHAR2(4000);
  V_DAYS  VARCHAR2(2);
BEGIN
  FOR I IN 1 .. 31 LOOP
    IF I < 10 THEN
      V_DAYS := '0' || I;
    ELSE
      V_DAYS := I;
    END IF;
    -- V_COUNT := V_COUNT + 1;
    IF I < 16 THEN
      SQLSTR := SQLSTR || ',max(case SUBJECT when ''D07' || V_DAYS ||
                ''' then COUNTI else 0 end) as ''D07' || V_DAYS || '''' ||
                CHR(10);    
    END IF;
  
  END LOOP;
  DBMS_OUTPUT.PUT_LINE(SQLSTR);
  DBMS_OUTPUT.PUT_LINE(LENGTHB(SQLSTR));
END;显示文本:“,max(case SUBJECT when 'D0716' then COUNTI else 0 end) as 'D0716'
,max(case SUBJECT when 'D0717' then COUNTI else 0 end) as 'D0717'
,max(case SUBJECT when 'D0718' then COUNTI else 0 end) as 'D0718'
,max(case SUBJECT when 'D0719' then COUNTI else 0 end) as 'D0719'
,max(case SUBJECT when 'D0720' then COUNTI else 0 end) as 'D0720'
,max(case SUBJECT when 'D0721' then COUNTI else 0 end) as 'D0721'
,max(case SUBJECT when 'D0722' then COUNTI else 0 end) as 'D0722'
,max(case SUBJECT when 'D0723' then COUNTI else 0 end) as 'D0723'
,max(case SUBJECT when 'D0724' then COUNTI else 0 end) as 'D0724'
,max(case SUBJECT when 'D0725' then COUNTI else 0 end) as 'D0725'
,max(case SUBJECT when 'D0726' then COUNTI else 0 end) as 'D0726'
,max(case SUBJECT when 'D0727' then COUNTI else 0 end) as 'D0727'
,max(case SUBJECT when 'D0728' then COUNTI else 0 end) as 'D0728'
,max(case SUBJECT when 'D0729' then COUNTI else 0 end) as 'D0729'
,max(case SUBJECT when 'D0730' then COUNTI else 0 end) as 'D0730'
,max(case ”
显示长度:1056 

解决方案 »

  1.   

    按你上面執行只有990個字符:66*15如果   IF I < 16 THEN去掉,則是:2046即66*31數據經測完全正常
      

  2.   

    我执行了下你的程序,结果是这样:
    ,max(case SUBJECT when 'D0701' then COUNTI else 0 end) as 'D0701'
    ,max(case SUBJECT when 'D0702' then COUNTI else 0 end) as 'D0702'
    ,max(case SUBJECT when 'D0703' then COUNTI else 0 end) as 'D0703'
    ,max(case SUBJECT when 'D0704' then COUNTI else 0 end) as 'D0704'
    ,max(case SUBJECT when 'D0705' then COUNTI else 0 end) as 'D0705'
    ,max(case SUBJECT when 'D0706' then COUNTI else 0 end) as 'D0706'
    ,max(case SUBJECT when 'D0707' then COUNTI else 0 end) as 'D0707'
    ,max(case SUBJECT when 'D0708' then COUNTI else 0 end) as 'D0708'
    ,max(case SUBJECT when 'D0709' then COUNTI else 0 end) as 'D0709'
    ,max(case SUBJECT when 'D0710' then COUNTI else 0 end) as 'D0710'
    ,max(case SUBJECT when 'D0711' then COUNTI else 0 end) as 'D0711'
    ,max(case SUBJECT when 'D0712' then COUNTI else 0 end) as 'D0712'
    ,max(case SUBJECT when 'D0713' then COUNTI else 0 end) as 'D0713'
    ,max(case SUBJECT when 'D0714' then COUNTI else 0 end) as 'D0714'
    ,max(case SUBJECT when 'D0715' then COUNTI else 0 end) as 'D0715'990
    完全没发现你说的问题。
      

  3.   

    10g的最大是2000,说是通过DBMS_OUTPUT.ENABLE (2000)可以设置,不过设置了好像不起作用,不大清楚了,不过这个是系统自带的,追究那么多做什么呢,达到自己想要的目的就可以了嘛~
    可以通过下面的方式分开显示,一样的哈~DECLARE
      SQLSTR  VARCHAR2(4000);
      V_DAYS  VARCHAR2(2);
      V_LENGTH NUMBER:=0;
    BEGIN
       FOR I IN 1 .. 31 LOOP
        V_DAYS:=LPAD(I,2,0);
          SQLSTR := ',max(case SUBJECT when ''D07' || V_DAYS ||
                    ''' then COUNTI else 0 end) as ''D07' || V_DAYS || ''''; 
        V_LENGTH:=V_LENGTH+LENGTH(SQLSTR);
        DBMS_OUTPUT.PUT_LINE(SQLSTR);  
      END LOOP;
      DBMS_OUTPUT.PUT_LINE('显示长度'||V_LENGTH);
    END;
      

  4.   

    打印是想做为调试语句来用,不是为了统计长度。
    因此想打印出来了,但Oracle显示不全