Skip to Main Content
  • Questions
  • How to load the XXXYY.msg files (error codes and messages) into the database

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Ashwin.

Asked: August 16, 2000 - 11:29 am UTC

Last updated: May 21, 2004 - 1:30 am UTC

Version: Oracle 7.3

Viewed 1000+ times

You Asked

Hi Tom,

I have created a table to transfer the Oracle Help like
ORA, DBA, FRM errors to this table now I have all these
errors in oracle help now how do i transfer these into text and
transfer to the table I have created. At Present I have created
a form and saving these records but it is very hard to type all
the 20000 records one by one into the form and save it to the
table. If U can tell me How do I transfer these type of Error
messages into the table it will be helpful.

The ORA errors are in the Form like Oracle help file ie. it is
the oracle errors help file so i would like to export only
the ora errors to a table that i have created in my database.

Regards
ash.

and Tom said...


Here is what I would do:

o load the msg file into a table, for example to get the US version of the ORA-XXXXX messages, i would load $ORACLE_HOME/rdbms/mesg/oraus.msg into a table virtually "as is" (just the relevant lines)

o I would use a stored procedure to massage the data and make it "relational".


For example, I would have 2 tables:

create TABLE temp_table
(
seqno number primary key ,
text varchar2(4000)
)
/

create table msg_table
( err_code number,
err_type varchar2(3),
err_msg varchar2(255),
err_text varchar2(4000),
primary key(err_code,err_type)
)
/


I would load the TEMP_TABLE using:


LOAD DATA
REPLACE
INTO TABLE temp_table
when (1:2) = '//'
(
text position(1:4096) ,
seqno recnum
)
INTO TABLE temp_table
when (1:1) <> '/'
(
text position(1:4096) ,
seqno recnum
)

with a sqlldr command line like:

$ sqlldr userid=u/p control=load.ctl data=$ORACLE_HOME/rdbms/mesg/oraus.msg


(thats on one line of course)...

And then using a stored procedure like:

create or replace procedure move_data( p_err_type in varchar2 )
as
l_last_err_code number;
l_last_err_msg varchar2(255);
l_last_err_text varchar2(4000);
l_n number;
l_sep char(1);
begin
for x in ( select * from temp_table order by seqno )
loop
if ( x.text not like '//%' ) then
begin
if ( l_last_err_code is NOT NULL ) then
insert into msg_table
( err_code, err_type, err_msg, err_text )
values
( l_last_err_code, p_err_type, l_last_err_msg,
l_last_err_text );
end if;

l_n := instr( x.text, ',' );
l_last_err_code := substr( x.text, 1, l_n-1 );
x.text := substr( x.text, l_n+1 );

l_n := instr( x.text, ',' );
l_last_err_msg := substr( x.text, l_n+1 );

l_last_err_text := NULL;
l_sep := NULL;
exception
when others then
dbms_output.put_line( x.text );
raise;
end;
else
l_last_err_text := l_last_err_text || l_sep ||
x.text;
l_sep := chr(10);
end if;
end loop;

if ( l_last_err_code is NOT NULL ) then
insert into msg_table
( err_code, err_type, err_msg, err_text )
values
( l_last_err_code, p_err_type, l_last_err_msg,
l_last_err_text );
end if;

end;
/

I can format the data correctly by executing:

SQL> exec move_data( 'ORA' );

Now, I can:

ops$tkyte@8i> select * from
2 msg_table where err_code = 54 and err_type= 'ORA';

ERR_CODE ERR
---------- ---
ERR_MSG
----------------------------------------------------------------------------------------------------
ERR_TEXT
----------------------------------------------------------------------------------------------------
54 ORA
"resource busy and acquire with NOWAIT specified"
// *Cause: Resource interested is busy.
// *Action: Retry if necessary.


which is the same answer I get with

ops$tkyte@8i> !oerr ora 54
00054, 00000, "resource busy and acquire with NOWAIT specified"
// *Cause: Resource interested is busy.
// *Action: Retry if necessary.





Rating

  (4 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

* * * * *

jonathan, January 12, 2003 - 5:21 pm UTC

what should i say? - amazing idea, great help and follow-up
i'm using the code now.

A reader, January 12, 2003 - 6:13 pm UTC

Tom --
I linked to the the above link, and did the load etc.
-- and it flies! I didn't really understand your formating
procedure, nor the reason for the massive error count, but
I continued on -- w/great results. Perfect. You ought to
copywrite that procedure.



A reader, May 20, 2004 - 8:39 am UTC

Tom,

Please reply me on this ...

SQL>  alter table TB_ETR003_GECI_ETMON_FINANCIAL disable constraint CN_ETR003001_FK1;

Table altered.

SQL> update TB_ETR001_GEIS_ETPROJECT set object_nam='issue oracle update issue' where object_nam='Or
acle update issue';

1 row updated.

SQL> 
SQL> update TB_ETR003_GECI_ETMON_FINANCIAL set object_nam='issue oracle update issue' where object_n
am='Oracle update issue';

50 rows updated.

SQL> alter table TB_ETR003_GECI_ETMON_FINANCIAL enable constraint CN_ETR003001_FK1;
alter table TB_ETR003_GECI_ETMON_FINANCIAL enable constraint CN_ETR003001_FK1
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified

SQL> commit;

Commit complete.

SQL> alter table TB_ETR003_GECI_ETMON_FINANCIAL enable constraint CN_ETR003001_FK1;
alter table TB_ETR003_GECI_ETMON_FINANCIAL enable constraint CN_ETR003001_FK1
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified


SQL>  SET constraints  all immediate;

Constraint set.

SQL> alter table TB_ETR003_GECI_ETMON_FINANCIAL enable constraint CN_ETR003001_FK1;
alter table TB_ETR003_GECI_ETMON_FINANCIAL enable constraint CN_ETR003001_FK1
*
ERROR at line 1:
ORA-00054: resource busy and acquire with NOWAIT specified


how to enable the constraint now? ..

thanks a lot 

Tom Kyte
May 20, 2004 - 11:41 am UTC

you have users using your table, you'll need to "stop them"

Thanks tom

A reader, May 21, 2004 - 1:30 am UTC


More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library