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