JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

[FEATURE] missing feature on parsing PL/SQL with "DECLARE" cluase

Open ZhengguanLi opened this issue 2 years ago • 1 comments

Grammar or Syntax Description

DECLARE clause is not supported yet

SQL Example

  • Simplified Query Example, focusing on the failing feature
    DECLARE 
        num NUMBER; 
    BEGIN 
        num := 10; 
    
        dbms_output.put_line('The number is ' || num); 
    END; 
    
  • Exception
    net.sf.jsqlparser.JSQLParserException: net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "num" <S_IDENTIFIER>
        at line 2, column 4.
    
    Was expecting one of:
    
        "@"
        "@@"
    

Additional context

The used JSQLParser Version: 4.6 State the applicable RDBMS and version: Oracle 19c Links to the reference documentation: N/A

ZhengguanLi avatar May 13 '23 00:05 ZhengguanLi

Greetings.

Those blocks exceed normal SQL Standard and can become very complex. See the example below. You will need to provide or sponsor an implementation to get those blocks supported. It will be some serious work.

DECLARE
  l_message  
  VARCHAR2 (100) := 'Hello';
BEGIN
  DECLARE
    l_message2     VARCHAR2 (100) := 
      l_message || ' World!'; 
  BEGIN
    DBMS_OUTPUT.put_line (l_message2);
  END;
EXCEPTION
  WHEN OTHERS
  THEN
    DBMS_OUTPUT.put_line 
   (DBMS_UTILITY.format_error_stack);
END;

manticore-projects avatar May 15 '23 07:05 manticore-projects