Skip to content

Instantly share code, notes, and snippets.

@xtender
Created January 27, 2024 04:20
Show Gist options
  • Save xtender/d7d529f6aed681b98abde56ae99b8f46 to your computer and use it in GitHub Desktop.
Save xtender/d7d529f6aed681b98abde56ae99b8f46 to your computer and use it in GitHub Desktop.
SQL error - error part position
create table ttt (aaa varchar2(10),bbb varchar2(10));
declare
cur integer;
str varchar2(100):='insert into ttt ("no","cols") values ("no such","column here")';
err_position int;
begin
cur := dbms_sql.open_cursor;
dbms_sql.parse(cur, str,
dbms_sql.native);
exception when others then
err_position:=dbms_sql.last_error_position;
dbms_output.put_line('Error at #'||err_position);
dbms_output.put_line(
substr(str,1,err_position-1)
||'>>>'
||substr(str,err_position,err_position+1)
||'<<<'
||substr(str,err_position+2)
);
dbms_output.put_line('Error stack:');
dbms_output.put_line (dbms_utility.format_error_stack);
dbms_sql.close_cursor(cur);
end;
/
Error at #48
insert into ttt ("no","cols") values ("no such">>>,"column here")<<<column here")
Error stack:
ORA-00984: column not allowed here
ORA-06512: at "SYS.DBMS_SQL", line 1134
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment