Home » SQL & PL/SQL » SQL & PL/SQL » Getting Column which caused the Exception (11g)
Getting Column which caused the Exception [message #293606] Mon, 14 January 2008 04:26 Go to next message
vishal gupta
Messages: 111
Registered: March 2001
Senior Member
Hi,
I am using Oracle 10g Rel 2 and currenly working on a project
which creates a repository and bulk inserts data into it using FORALL statment.
I am using SAVE Exceptions to save the errors in a table and then report to the user about these errors.

My question is ,can i somehow know the column which caused the exception ?
Currently ,we can save only SQLCODE and SQLERRM .
Is there any possibility that I get to know the column also which raised the exception ?
For example ,during a insert ,if column raises exception

ORA-01438: value larger than specified precision allows for this column

Is it possible for me know using some programming technique that which column raised this exception ?


Regards
Re: Getting Column which caused the Exception [message #293610 is a reply to message #293606] Mon, 14 January 2008 04:30 Go to previous messageGo to next message
Michel Cadot
Messages: 68765
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
No there is no way before 11g.

Regards
Michel
Re: Getting Column which caused the Exception [message #293616 is a reply to message #293606] Mon, 14 January 2008 04:55 Go to previous messageGo to next message
vishal gupta
Messages: 111
Registered: March 2001
Senior Member
Thanks Michel for your response.
Although I am not using 11g,can you direct me to some oracle documentation on this feature?

Regards
Re: Getting Column which caused the Exception [message #293622 is a reply to message #293616] Mon, 14 January 2008 05:07 Go to previous messageGo to next message
Michel Cadot
Messages: 68765
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
SQL> create table t (c1 varchar2(10),c2 varchar2(3));

Table created.

SQL> insert into t values ('123456789','123456789');
insert into t values ('123456789','123456789')
                                  *
ERROR at line 1:
ORA-12899: value too large for column "MICHEL"."T"."C2" (actual: 9, maximum: 3)

Regards
Michel
Re: Getting Column which caused the Exception [message #293631 is a reply to message #293606] Mon, 14 January 2008 05:38 Go to previous messageGo to next message
vishal gupta
Messages: 111
Registered: March 2001
Senior Member
Thanks Michel.
Re: Getting Column which caused the Exception [message #293655 is a reply to message #293610] Mon, 14 January 2008 07:31 Go to previous messageGo to next message
MarcS
Messages: 312
Registered: March 2007
Location: Antwerp
Senior Member
Michel Cadot wrote on Mon, 14 January 2008 11:30

No there is no way before 11g.

Regards
Michel



Are you sure about that 11g ???

Reason I ask: we're on 10.2 and we have had that more descriptive error-message ever since.

I've run a quick test, but the error-message only applies/appears on CHAR/VARCHAR fields.
Re: Getting Column which caused the Exception [message #293659 is a reply to message #293655] Mon, 14 January 2008 08:03 Go to previous messageGo to next message
Michel Cadot
Messages: 68765
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
You're right! It also works in 10.2, I was quite sure it was introduced in 11.
Thanks for the correction.

Regards
Michel
Re: Getting Column which caused the Exception [message #293779 is a reply to message #293659] Mon, 14 January 2008 22:52 Go to previous messageGo to next message
vishal gupta
Messages: 111
Registered: March 2001
Senior Member
Thanks MarcS for clarification.
You are right ,it does give a proper message in case of character field but not in case of number.

Regards
Re: Getting Column which caused the Exception [message #488637 is a reply to message #293655] Mon, 10 January 2011 05:33 Go to previous messageGo to next message
rfadzi
Messages: 3
Registered: January 2011
Location: CAPE
Junior Member
I am saving the actual error using save exceptions on 11g but i dont seem to get the column name :

Error: ORA-12899: value too large for column (actual: , maximum: )

Here is my code for exception handling:

EXCEPTION
WHEN save_attr_except THEN
errors := SQL%BULK_EXCEPTIONS.COUNT;
FOR k IN 1 .. errors LOOP
l_iteration := SQL%BULK_EXCEPTIONS(k).ERROR_INDEX;
dbms_output.put_line(
'Error: ' ||
SQLERRM(-sql%BULK_EXCEPTIONS(k).ERROR_CODE) ||
' -> ' || DBMS_UTILITY.format_error_backtrace);
END LOOP;
BULK INSERT - column name [message #488644 is a reply to message #293606] Mon, 10 January 2011 05:53 Go to previous messageGo to next message
rfadzi
Messages: 3
Registered: January 2011
Location: CAPE
Junior Member
I am using FORALL to insert records into a table and SAVE EXCEPTIONS to log errors.

I have this error but i cant get the error message to have the column name:

Error: ORA-12899: value too large for column (actual: , maximum: )

Re: BULK INSERT - column name [message #488649 is a reply to message #488644] Mon, 10 January 2011 06:15 Go to previous messageGo to next message
Michel Cadot
Messages: 68765
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Do not multipost your question.
Once is sufficient for us to see it.

Regards
Michel
Re: BULK INSERT - column name [message #488693 is a reply to message #488644] Mon, 10 January 2011 11:04 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9106
Registered: November 2002
Location: California, USA
Senior Member
Without the save exceptions, you get the column name, actual size, and maximum allowable size. With the save exceptions, you do not. This is documented behavior. With the save exceptions, it uses the error code to retrieve the error message, but this cannot retrieve the values. Of course, without the save exceptions, processing stops at the first error. Please see the demo below, first without then with the save exceptions.

-- test environment:
SCOTT@orcl_11gR2> SELECT * FROM v$version
  2  /

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE	11.2.0.1.0	Production
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production

5 rows selected.

SCOTT@orcl_11gR2> CREATE TABLE emp_temp AS
  2  SELECT deptno, job
  3  FROM   EMP
  4  WHERE  1 = 2
  5  /

Table created.

SCOTT@orcl_11gR2> DESC emp_temp
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 DEPTNO                                             NUMBER(2)
 JOB                                                VARCHAR2(9)


-- without save exceptions:
SCOTT@orcl_11gR2> DECLARE
  2    TYPE	      emp_rec IS RECORD
  3  	 (deptno      emp.deptno%TYPE,
  4  	  job	      emp.job%TYPE);
  5    TYPE	      emp_tab IS TABLE OF emp_rec;
  6    emps	      emp_tab;
  7    e_too_big      EXCEPTION;
  8    PRAGMA	      EXCEPTION_INIT (e_too_big, -12899);
  9  BEGIN
 10    SELECT deptno, job
 11    BULK   COLLECT
 12    INTO   emps
 13    FROM   emp
 14    WHERE  deptno = 10;
 15    FORALL i IN 1 .. emps.COUNT
 16  	 INSERT INTO emp_temp VALUES
 17  	 (emps(i).deptno, emps(i).job || 'S');
 18  EXCEPTION
 19    WHEN e_too_big THEN
 20  	 DBMS_OUTPUT.PUT_LINE (SQLERRM);
 21  END;
 22  /
ORA-12899: value too large for column "SCOTT"."EMP_TEMP"."JOB" (actual: 10,
maximum: 9)

PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> SELECT * FROM emp_temp
  2  /

    DEPTNO JOB
---------- ---------
        10 MANAGERS

1 row selected.

SCOTT@orcl_11gR2> TRUNCATE TABLE emp_temp
  2  /

Table truncated.


-- with save exceptions:
SCOTT@orcl_11gR2> DECLARE
  2    TYPE	      emp_rec IS RECORD
  3  	 (deptno      emp.deptno%TYPE,
  4  	  job	      emp.job%TYPE);
  5    TYPE	      emp_tab IS TABLE OF emp_rec;
  6    emps	      emp_tab;
  7    save_attr_except     EXCEPTION;
  8    PRAGMA	      EXCEPTION_INIT (save_attr_except, -24381);
  9    errors	      NUMBER;
 10    l_iteration    VARCHAR2(100);
 11  BEGIN
 12    SELECT deptno, job
 13    BULK   COLLECT
 14    INTO   emps
 15    FROM   emp
 16    WHERE  deptno = 10;
 17    FORALL i IN 1 .. emps.COUNT SAVE EXCEPTIONS
 18  	 INSERT INTO emp_temp VALUES
 19  	 (emps(i).deptno, emps(i).job || 'S');
 20  EXCEPTION
 21    WHEN save_attr_except THEN
 22  	 errors := SQL%BULK_EXCEPTIONS.COUNT;
 23  	 FOR k IN 1 .. errors LOOP
 24  	   l_iteration := SQL%BULK_EXCEPTIONS(k).ERROR_INDEX;
 25  	   dbms_output.put_line(
 26  	     'Error: ' ||
 27  	     SQLERRM(-sql%BULK_EXCEPTIONS(k).ERROR_CODE) ||
 28  	     ' -> ' || DBMS_UTILITY.format_error_backtrace);
 29  	 END LOOP;
 30  END;
 31  /
Error: ORA-12899: value too large for column  (actual: , maximum: ) ->
ORA-06512: at line 17


PL/SQL procedure successfully completed.

SCOTT@orcl_11gR2> SELECT * FROM emp_temp
  2  /

    DEPTNO JOB
---------- ---------
        10 MANAGERS
        10 CLERKS

2 rows selected.

SCOTT@orcl_11gR2>

[Updated on: Fri, 21 January 2011 09:23]

Report message to a moderator

Re: BULK INSERT - column name [message #490164 is a reply to message #488693] Fri, 21 January 2011 07:50 Go to previous message
rfadzi
Messages: 3
Registered: January 2011
Location: CAPE
Junior Member
thanks for the reply
Previous Topic: Advance Query Required
Next Topic: VALUE TOO LARGE FOR VARIABLE
Goto Forum:
  


Current Time: Wed Aug 13 15:58:25 CDT 2025