★ wanayoo — archive 1999 https://github.com/JSQLParser/JSqlParser/issues/1061Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PL/SQL Blocks Parsing Error #1061

Open
kaplan441 opened this issue Oct 9, 2020 · 0 comments
Open

PL/SQL Blocks Parsing Error #1061

kaplan441 opened this issue Oct 9, 2020 · 0 comments

Comments

@kaplan441
Copy link

@kaplan441 kaplan441 commented Oct 9, 2020

When I parse a oracle pl sql block script then it throws exception.

PLSQL:

DECLARE
    P_VARIABLE   NUMBER := 0;

    CURSOR C IS
        SELECT A.ROWID     AS RD
          FROM TABLE_NAME A;
BEGIN
    FOR R IN C
    LOOP
        UPDATE TABLE_NAME A
           SET A.COL1 = 2
         WHERE ROWID = R.RD;

        P_VARIABLE := P_VARIABLE + 1;

        IF MOD (P_VARIABLE, 2000) = 0
        THEN
            COMMIT;
        END IF;
    END LOOP;

    COMMIT;
    DBMS_OUTPUT.PUT_LINE ('COMMIT COUNT: ' || TO_CHAR (P_VARIABLE));
EXCEPTION
    WHEN OTHERS
    THEN
        RAISE;
END;

Exception 1 ;
Encountered unexpected token: "P_VARIABLE" at line 2, column 5. Was expecting one of: "@" "@@"
Exception 2:
I removed variable then occured CURSOR exception
Encountered unexpected token: "CURSOR" at line 2, column 5. Was expecting one of: "@" "@@"

Exception 3:
I changed to code like,

BEGIN
    FOR R IN C
    LOOP
        UPDATE TABLE_NAME A
           SET A.COL1 = 2
         WHERE ROWID = R.RD;

        P_VARIABLE := P_VARIABLE + 1;

        IF MOD (P_VARIABLE, 2000) = 0
        THEN
            COMMIT;
        END IF;
    END LOOP;

    COMMIT;
    DBMS_OUTPUT.PUT_LINE ('COMMIT COUNT: ' || TO_CHAR (P_VARIABLE));
EXCEPTION
    WHEN OTHERS
    THEN
        RAISE;
END;

Then it throwed this exception;
Encountered unexpected token: "FOR" "FOR" at line 2, column 5. Was expecting one of: "(" ";" "ALTER" "BEGIN" "CALL" "COMMENT" "COMMIT" "CREATE" "DECLARE" "DELETE" "DESCRIBE" "DROP" "EXEC" "EXECUTE" "EXPLAIN" "GRANT" "INSERT" "MERGE" "REPLACE" "SET" "SHOW" "TRUNCATE" "UPDATE" "UPSERT" "USE" "VALUES" "WITH"

New keywords;
CURSOR
FOR LOOP
BEGIN EXCEPTION END
DECLARE

My java version 11
JSqlParser version 3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.