LAST_ERROR_POSITION returns the position of the last syntax error in the SQL statement text passed to DBMS_SQL.PARSE.
When an error occurs in the SQL statement passed to DBMS_SQL.PARSE, immediately call DBMS_SQL.LAST_ERROR_POSITION to obtain the position of the error.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
DBMS_SQL.LAST_ERROR_POSITION
RETURN INTEGER;
Return value
Returns an INTEGER value indicating the byte offset in the SQL statement text where the error occurred.
Examples
In the following example, the SQL statement select * form dual on the fifth line mistakenly uses form instead of from, causing an error. Immediately calling DBMS_SQL.LAST_ERROR_POSITION() will return the position of the error.
obclient > DECLARE
CUR NUMBER;
BEGIN
CUR:=dbms_sql.open_cursor;
dbms_sql.parse(CUR,'select * form dual',dbms_sql.native);
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('error pos: ' || dbms_sql.last_error_position());
END;
/
Query OK, 1 row affected
error pos: 9
