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

Unable to parse the oracle query when query has 'FOR UPDATE' Clause #2216

Closed
sashindeitidata opened this issue Sep 14, 2023 · 0 comments
Closed

Comments

@sashindeitidata
Copy link

Hello Team,
Warm greetings!

Parser is unable to parse query when FOR UPDATE Clause is used.

Following query works fine in oracle-

select col1, col2 into l_col1, l_col2
from table
where ...
for update;

This is used to lock the select query incase other session is trying to update the same data or column.

Oracle Documentation -
https://stackoverflow.com/questions/66247423/why-we-need-select-for-update-in-oracle-sql
https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqlj31783.html
https://docs.oracle.com/javadb/10.8.3.0/ref/rrefsqlj41360.html#rrefsqlj41360

Code for your reference -

import sqlglot.expressions as exp

query ="""
select col1, col2 into l_col1, l_col2
from table
where col1 > 10
for update
"""

expressions = sqlglot.parse_one(query, read='oracle')
x = list(expressions.find_all(exp.Table))

for i in x:
  listTables = str(i).split(' ')[0]
  print(listTables)

Note that above query is a valid oracle query.

query fails as it cannot process for update clause.
Request you to add support for the same.

Thanks ton in advance!

Thanks,
Sachin

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

No branches or pull requests

1 participant