日期:2014-05-17  浏览次数:20939 次

声明变量长度与实际内容不符
varchar2(2000) 为什么内容长度只有1056多,剩余的就显示不了呢,实际内容2100

使用语句:
SQL code

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 


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