Skip to content

PL/iSQL Parser Rejects Parentheses in SELECT INTO Expression #981

Closed

Description

@rophy

IvorySQL Version

commit 0a43e33

OS Version (uname -a)

Linux 6.8.0-87-generic

Configuration options (config.status --config)

'--prefix=/home/ivorysql/ivorysql' '--enable-debug' '--enable-cassert' '--with-uuid=e2fs' '--with-libxml'

Current Behavior

IvorySQL's PL/iSQL parser rejects SELECT INTO statements when the selected expression is wrapped in parentheses:

ERROR:  syntax error at or near "select"
LINE 6:   SELECT (100 - x) * 0.01 INTO result FROM dual;
               ^

Expected behavior/code

Oracle PL/SQL accepts parenthesized expressions in SELECT INTO statements. The same code runs successfully in Oracle:

Test with parentheses: .5
Expected: 0.5
PL/SQL procedure successfully completed.

Step to reproduce

Run the following code in IvorySQL Oracle compatibility mode (port 1521):

SET SERVEROUTPUT ON;

-- Test: Parenthesized expression in SELECT INTO
DECLARE
  x NUMBER := 50;
  result NUMBER;
BEGIN
  SELECT (100 - x) * 0.01 INTO result FROM dual;
  DBMS_OUTPUT.PUT_LINE('Test with parentheses: ' || result);
  DBMS_OUTPUT.PUT_LINE('Expected: 0.5');
END;
/

Workaround

Use a temporary variable to maintain correct calculation:

DECLARE
  temp NUMBER;
BEGIN
  SELECT 100 INTO temp FROM dual;
  result := (temp - x) * 0.01;
END;

Activity

  1. added
    bug
    on Nov 26, 2025
  2. yuanyl630 commented on Nov 27, 2025

    @yuanyl630
    Contributor

    Thanks for reporting this! I've verified the issue in the codebase.

    The problem is in the PL/iSQL parser - it misidentifies SELECT (expression) syntax. This affects any SELECT statement where the first item after SELECT is wrapped in parentheses.

    Your workaround using a temporary variable is correct for now. This should be fixed to ensure full Oracle PL/SQL compatibility.

  3. OreoYang commented on Nov 27, 2025

    @OreoYang
    Contributor

    /assign

  4. added theissue type on Dec 1, 2025
  5. moved this from Backlog to Done in IvorySQL 5.1on Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions