sqlglot 30.8.0
Oracle dialect
"WITH FUNCTION" in a query causes parsing error Expecting (. Line 1, Col: 20.
Query:
WITH FUNCTION f_demo(v_in_ch IN CHAR) RETURN CHAR
IS
BEGIN
RETURN v_in_ch;
END;
SELECT
'C' || f_demo('d')
FROM dual;
Repo code:
import sqlglot
query = """WITH FUNCTION f_demo(v_in_ch IN CHAR) RETURN CHAR
IS
BEGIN
RETURN v_in_ch;
END;
SELECT
'C' || f_demo('d')
FROM dual;"""
try:
ast = sqlglot.parse_one(query,read="oracle")
except sqlglot.ParseError as p:
print('Parsing error!')
print(p)
except Exception as e:
print(type(e))
print(e)
Results:
py .\withfunctionerror.py
Parsing error!
Expecting (. Line 1, Col: 20.
WITH FUNCTION f_demo(v_in_ch IN CHAR) RETURN CHAR
IS
BEGIN
RETURN v_in_ch;
END;
SELECT
'C' || f_demo('d')
FROM
Query runs fine producing output 'Cd' under Oracle 19c
sqlglot 30.8.0
Oracle dialect
"WITH FUNCTION" in a query causes parsing error
Expecting (. Line 1, Col: 20.Query:
Repo code:
Results:
Query runs fine producing output 'Cd' under Oracle 19c