Can Oracledb._Error show the error location in "Lines and Columns"? #214
-
Can Oracledb._Error show the error location in "Lines and Columns"? In case of SQL errors I have checked the documentation,
can be retrieved, but it does not seem to be able to receive messages like "Line:X and Column:Y". Also, I think it is possible to calculate from Offset, but is there already such a function available? Reference |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
To solve the problem, I wrote the following code in python. However, if it already exists, I would like to use an existing one. def calculate_line_and_column(query, offset):
lines = query.split("\n")
total_offset = 0
for line_num, line in enumerate(lines, start=1):
total_offset += len(line) + 1 # Add 1 for the newline character
if total_offset > offset:
column_num = offset - (total_offset - len(line))
return line_num, column_num |
Beta Was this translation helpful? Give feedback.
There is no method currently to calculate the line and column from the offset. If you would like to see this included in python-oracledb, please create an enhancement issue from this discussion.