The LAST_ERROR_POSITION function returns the location of the syntax error in the last call of DBMS_SQL.PARSE.
When an error occurs in an SQL statement in DBMS_SQL.PARSE, you can immediately call DBMS_SQL.LAST_ERROR_POSITION to obtain the location of the error.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition provides only the MySQL mode.
Syntax
DBMS_SQL.LAST_ERROR_POSITION
RETURN INTEGER;
Return values
An INTEGER value is returned, indicating the byte offset in the SQL statement text where the error occurred.
Examples
In the following example, from in the SQL statement select * form dual, which is in the fifth line, is incorrectly spelled as form. An exception occurs. The error location is returned when you call DBMS_SQL.LAST_ERROR_POSITION().
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