0
votes

well I'm pretty new to plSQL and I can't seem to figure out some errors I'm getting while trying to generate a pascal's triangle

Here's the code:

SET SERVEROUTPUT ON;
DECLARE
    N NUMBER;
    I NUMBER;
    J NUMBER;
    K NUMBER;
    L NUMBER;
    T NUMBER;
    S NUMBER;
BEGIN
    DBMS_OUTPUT.PUT_LINE('ENTER THE LIMIT');
    N:=&N; 
    I:=0;
    T:=N-2;
    S:=0;
    L:=0;
    WHILE (I<N) LOOP
        J:=0;
        WHILE (J<T) LOOP
            DBMS_OUTPUT.PUT(' ');
            J:=J+1;
        END LOOP;
        K:=0;
        WHILE (K<=S) LOOP
            IF (K<=I) THEN
                DBMS_OUTPUT.PUT(K+1);
                L:=K;
            ELSE
                L:=L-1;
                DBMS_OUTPUT.PUT(L+1);
            END IF;
            K:=K+1;
        END LOOP;
        DBMS_OUTPUT.PUT_LINE('');
        T:=T-1;
        S:=S+2;
    END LOOP;
END;

The errors are

Error report - ORA-20000: ORU-10027: buffer overflow, limit of 1000000 bytes ORA-06512: at "SYS.DBMS_OUTPUT", line 32 ORA-06512: at "SYS.DBMS_OUTPUT", line 97 ORA-06512: at line 29 20000. 00000 - "%s" *Cause: The stored procedure 'raise_application_error' was called which causes this error to be generated. *Action: Correct the problem as described in the error message or contact the application administrator or DBA for more information.

2
its coming from dbms_output. It can only hold so much data before it blows up. You can create a CLOB if you need to - tbone
thanks for the link but i don't really need the code, rather if you could tell me what is the reason for the errors generated, i will be grateful - Soutrik Mukherjee

2 Answers

0
votes

The problem you're having has to do with SQL*Plus, the Oracle SQL client, rather than PL/SQL, the programming language. Change the line which says SET SERVEROUTPUT ON to

SET SERVEROUTPUT ON SIZE UNLIMITED

This error may, however, indicate you've got an infinite loop, so be careful. Note that I never appears to be incremented and N is never decremented, so the loop started at WHILE (I<N) LOOP may not terminate.

Best of luck.

0
votes

Neither I nor N are ever updated, so you have an infinite loop. Other than that, the error is indicating that the DBMS_OUTPUT buffer is being exceeded. It's default buffer size is 1,000,000 bytes, though you can adjust that with an appropriate DBMS_OUTPUT.ENABLE call or SET SERVEROUTPUT SIZE statement.