Capture Oracle errors
Hi, I have a problem: I am inserting information from a table to many other tables, but if there's an error(for example, duplicate primary key), I have to put this information in a log... I have two questions: the log should be another table(for example with the sysdate and a description of the error)? The other: How can I register the Oracle errors in the log?
Thanks
Hi,
New in 10g, maybe you are on an earler version?
(Or maybe you just lack execute privilege on dbms_errlog)
In 9i an option could be [FORALL ... SAVE EXCEPTIONS|http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/05_colls.htm#32392], but it's a lot more clumpsy to work with.
If you are looking for a simple logging framework, you can have a look at [log4plsql|http://log4plsql.sourceforge.net/]
Regards
Peter
Edited by: Peter on Nov 24, 2009 10:43 AM
- Added link to log4plsql
Similar Messages
-
Capturing oracle error codes into a variable
Hi
Can someone show me how it is possible to save an Oracle defined error code into a variable? What I am trying to do is when a stored procedure fails an Oracle error is raised, such as ORA-xxxx, then pass this code into variable to be saved into a log.
How do I achieve this?user633278 wrote:
How do I achieve this?Function SQLCODE in PL/SQL exception handler returns error code. SQLERRM returns message:
SQL> declare
2 x number;
3 begin
4 x := 1/0;
5 exception
6 when others
7 then
8 dbms_output.put_line('Error code: ' || SQLCODE);
9 dbms_output.put_line('Error message: ' || SQLERRM);
10 end;
11 /
Error code: -1476
Error message: ORA-01476: divisor is equal to zero
PL/SQL procedure successfully completed.
SQL> SY. -
Capturing Oracle Error Messages
Hi when developing some applications, I come across some error messages that I would like to make custom error messages.
for example: ORA-00001: unique constraint (CREATE_USER.IC_ITEM_GENDERS_PK) violated
Is there a way to capture this message and then make a user friendly message. Any info. would be great.
ThanksIf you write your own after-submit processes, you can write an appropriate exception handler, something like
begin
exception when dup_val_on_index -- ORA-0001
then :P1_ERROR := 'Nice error message';
end;Then show some "Error" HTML region with &P1_ERROR. conditional upon P1_ERROR being not null.
AFAIK, there is no way to do this when the error is raised by the wizard-generated automatic DML or MRU processes. For that, you could try to put your error checking code in a Validation (and specify your nice error message). If the validation fails, the after-submit processes are not fired so the "ugly" error messages will not be seen by the user.
Hope this helps. -
To capture unix error in oracle
Hi,
when a pl/sql procedure is called through unix shell scripting, if the script is errored out due to any reason , i need to capture the error details in another table using unix. it it possible instead of capturing the errores in table level inside the procedure.PL/SQL 101 : Exception Handling
-
I want to handle an Oracle Error in my code where the "execute immediate" statement comes to play.
My code goes against several tables
ID_TABLE_08
ID_TABLE_07
ID_TABLE_06
If table does not exist in database (ie: ID_TABLE_05) I get : Oracle Error ORA-0942 table or view does not exist.
How can I capture and handle this error so
1. The code will continue to run getting the next value
2. The bad record still will get written in to a table called bad_table.
v_year := TO_CHAR (pp_eff_dtg (indx), 'yy');
BEGIN
EXECUTE IMMEDIATE
'SELECT DISTINCT ID_number
FROM ID_TABLE_'|| v_year||'
WHERE NAME = :NAME
AND EFFECTIVE_DATE = : EFFECTIVE_DATE
INTO v_ID_number
USING pp_NAME (indx),
pp_eff_dtg (indx);
GOTO END_LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
GOTO INSERT_ADD_RECORD;
END;
Thank you for your help!if you want to handle a specific oracle error number you can also declare an exception, match that exception to the error number and handle it.
Like this (not syntax checked)
declare
e_table_does_not_exist exception;
pragma exception_init (-942,e_table_does_not_exist); -- I hope I got the parameters in the right order
begin
EXECUTE IMMEDIATE('select * from ID_TABLE_'|| v_year||' where ...');
exception
when e_table_does_not_exist then -- handle specific error
raise_application_error(-20001,'The table ID_TABLE_'|| v_year||' could not be found. Next time enter a valid year!');
end; -
Log unsuccessful attemps connecting to database+Oracle error
Hi,
I've a simple trigger to log all user's unsuccessful attempts to connect to a database for the oracle error:ora-1017( invalid username/password when trying to login)
CREATE TABLE connection_audit (
login_date DATE,
username VARCHAR2(30));
-- trigger to trap unsuccessful logons
CREATE OR REPLACE TRIGGER T_LOGON_FAILURES
AFTER SERVERERROR
ON DATABASE
BEGIN
IF (IS_SERVERERROR(1017)) THEN
INSERT INTO connection_audit
(login_date, username)
VALUES
(SYSDATE, 'ORA-1017');
END IF;
END T_LOGON_FAILURES;
Now, I would've to log the unsuccessful attempts due to whatever Oracle error, along with the oracle error.
Can someone help me with the code changes?
Thanks,
BhagatI've created a trigger which inserts a record into table SERVERERROR_LOG for
every server error.
CREATE OR REPLACE TRIGGER T_LOG_SERVER_ERRORS
AFTER SERVERERROR ON DATABASE
** Purpose: T_LOG_SERVER_ERRORS TRIGGER -- THE SERVERERROR TRIGGER TAKES EVERY SERVER ERROR GENERATED
** FROM ORACLE PL/SQL AND PLACES IT INTO AN ORACLE TABLE.
** BY CAPTURING THE USER ID AND THE TIME OF THE ERROR, THE ORACLE ADMINISTRATOR WOULD BE
** IMMEDIATELY BE NOTIFIED VIA E-MAIL WHENEVER A SERVER ERROR OCCURS.
DECLARE
ls_user varchar2(30);
ls_osuser varchar2(30);
ls_machine varchar2(64);
ls_process varchar2(9);
ls_program varchar2(48);
BEGIN
SELECT username,osuser,machine,process,program
INTO ls_user,ls_osuser,ls_machine,ls_process,ls_program
FROM V$SESSION
WHERE audsid=userenv('sessionid');
INSERT INTO SERVERERROR_LOG
VALUES(
dbms_standard.server_error(1),
localtimestamp,
ls_user,
ls_osuser,
ls_machine,
ls_process,
ls_program);
END;
And My procedure below queries the table and notifies the Oracle Admin by
E-mail for every server error.(P_NOTIFY_SERVER_ERR is the procedure which does the job of sending mail to Admin).
PROCEDURE P_SERVER_ERRORS
AS
** Purpose: PROCEDURE FOR CHECK FOR SERVER ERRORS .
** INVOKE THE PROCEDURE P_NOTIFY_SERVER_ERR,WHICH NOTIFIES THE ORACLE ADMIN
** EVERYTIME SERVER ERROR OCCURS.
CURSOR C_SERVERERROR_LOG
IS
SELECT * FROM SERVERERROR_LOG;
BEGIN
FOR lc_servererror_log IN c_servererror_log
LOOP
P_NOTIFY_SERVER_ERR(lc_servererror_log.error,
lc_servererror_log.error_dt_time,
lc_servererror_log.username,
lc_servererror_log.osuser,
lc_servererror_log.machine,
lc_servererror_log.process,
lc_servererror_log.program);
END LOOP;
END P_SERVER_ERRORS;
An Oracle job executes procedure P_SERVER_ERRORS once every 5 minutes.
Thanks every one for your valuable suggestion.
Cheers!!!!
Regards,
Bhagat -
Hi,
How do I capture the oracle error number and message in an exception and display that to the user?
Thanks,
ephsanNote that 99% of the time, you want to re-raise the exception if all you can do is log it to a table. Otherwise, the calling code never knows that an error occurred and continues on unaware, which is rarely what you want because it generally causes more errors to be raised down the line.
Justin -
Oracle errors in Weblogic Error logs appear in non english
We have a problem with weblogic error logging. Specifically, in a managed server's log file, Oracle errors such as ORA-XXXX show in Greek, not English. We are assuming
that this is because the timezone is Europe/Athens. However, the weblogic application server runs with user.language=en, user.country=US. What's more, there are 4 application servers and 2 of them have this problem. The oracle database is accessed via weblogic datasources.
Oracle database server Setup: Oracle Server 11gR2 running on Oracle Linux 64 bit, timezone set to Europe/Athens
Weblogic Server: Weblogic 10.3.5 running on Oracle Linux 64 bit, timezone set to Europe/Athens
The managed server, according to jrockit, the jvm runs with the following language related system properties:
user.language=en, user.country=US, user.timezone=Europe/Athens
The question is: How do we tell oracle / weblogic to log english text for the ORA errors?
Thanks,
ChrisI digged in the weblogic installation directory and it seems like the domain configuration wizard messed up the jdbc configs for the data sources.
The config xml files for the data sources in the /domain root/config/jdbc directory had oracle driver but the test query was for pointbase. I double checked from the database.xml file in the init-info directory and corrected the entry in the datasource config xmls and voila!.. the errors were gone.
I am not sure if this was the right approach and whether i have solved the issue or simply patched it.. so I am keeping the question open. If any one has any inputs I will be grateful.
If the mods/admins feel that the thread should be marked as solved I will surely do so.
Thanks. -
Download Helper Screen Capture worked to capture video if the default "no audio" option is active. But, no audio. The "speakers" or "microphone" audio options are confusing....the audio to be captured is from the video, so what do you choose? With either "speakers" or "microphone" selected, the captured file has poor audio and no video. Re-capture efforts (speakers) get "Invalid capture file error" and "File Creation error- Unable to rename/copy audio file"
The paid upgrade of "Converter" doesn't work.
Instructive documentation - not very good.
Suggestions - Need time delay between initiation of "Record" and starting the video to be recorded.
Could use timer tracking of the record process.
Are there operating system limitations? (Have Windows XP Pro)That is an issue for the developer of that Download Helper.
-
[SOLVED] FRM-40508:ORACLE error: unable to INSERT record
Hi all,
I have migrated this form from 4.5 to 10g (Version 10.1.2.0.2 ). This form inserts a record into the database table when all the fields in the form are filled and a button Save is presed.
At the time when I press the Save button, I get this error. FRM-40508:ORACLE error: unable to INSERT record
So I went on to see the "Display Error" from help and found to be the database error, inserting into a table.
The error message is ORA-00932: inconsistent datatypes: expected DATE got NUMBER
The form where I press Save button has 3 date fields and I checked the properties of them and they are Date only.
I also generated to object list report and tried to find some answer, but no use.
Please help me in debugging this form.
Edited by: Charan on Aug 18, 2011 4:05 PMI think you need to get a description of the table and compare all the "database" columns in the form with the ones in the database table to see that the types match. Somewhere there's a mismatch. Also check the block(s) "query data source columns" and see if there's any
columns in there that the type does not match the table. (check the sizes of things too while you're at it.) -
Oracle error 1012 ("Not Logged On") & AUTOTRAN=Y
Hi.
I have a problem trying to access an Oracle 8.0.6
database from a 6.5 Tuxedo server.
Both TMS and server execute tpopen correctly
All services are declared as AUTOTRAN
Everything seems to be OK according to the logsgenerated by Oracle XA libraries
However, I always get the Oracle error 1012 ("Not Logged On")
when executing SQL statements from my pro*C server.
I just can't figure out why this error occurs.
I also tried to explicitly open a transaction from the client,
but the result is exactly the same (tpbegin is successfull,
however).
Could someone help me to make this work ?
Thanks.Solved by removing "DB=<db>" from my OPENINFO string, as far as this parameter
should only be used when using proc*C "EXEC SQL ... AT <db>" statements.
"Mathieu Chauvin" <[email protected]> wrote:
>
Hi.
I have a problem trying to access an Oracle 8.0.6
database from a 6.5 Tuxedo server.
Both TMS and server execute tpopen correctly
All services are declared as AUTOTRAN
Everything seems to be OK according to the logsgenerated by Oracle XA libraries
However, I always get the Oracle error 1012 ("Not Logged On")
when executing SQL statements from my pro*C server.
I just can't figure out why this error occurs.
I also tried to explicitly open a transaction from the client,
but the result is exactly the same (tpbegin is successfull,
however).
Could someone help me to make this work ?
Thanks. -
Capture an error while creating a purchase requisition (BAPI_PR_CREATE)
Hi All,
I am using FM BAPI_PR_CREATE to create purchase requesition, Now my problem is that i have various items for single material now i wan to capture the error if any item has ?
Please let me know how to do so?
Thanks & Regards,
Ruchi TiwariHi,
To get the error messages after the BAPI_PR_CREATE is called,
loop at the return table which will contain the system messages and call the following FM
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = LS_MESSAGES-MSGID
LANG = '-D'
NO = LS_MESSAGES-MSGNR
V1 = LS_MESSAGES-MSGV1
V2 = LS_MESSAGES-MSGV2
V3 = LS_MESSAGES-MSGV3
V4 = LS_MESSAGES-MSGV4
IMPORTING
MSG = LV_MESSAGE
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF. -
Oracle error ORA-01461when trying to insert into an ORACLE BLOB field
I am getting Oracle error ‘ORA-01461: can bind a LONG value only for insert into a LONG column' when trying to insert into an ORACLE BLOB field. The error occurs when trying to insert a large BLOB (JPG), but does not occur when inserting a small (<1K) picture BLOB.(JPG). Any ideas?
BTW, when using a SQL Server datasource using the same code.... everything works with no problems.
ORACLE version is 11.2.0.1
The ORACLE datasource is JDBC using Oracle's JDBC driver ojdbc6.jar v11.2.0.1 (I also have tried ojdbc5.jar v11.2.0.1; ojdbc5.jar v11.2.0.4; and ojdbc6.jar v11.2.0.4 with the same error result.)
Here is my code:
<cfset file_mime = Lcase(Right(postedXMLRoot.objname.XmlText, 3))>
<cfif file_mime EQ 'jpg'><cfset file_mime = 'jpeg'></cfif>
<cfset file_mime = 'data:image/' & file_mime & ';base64,'>
<cfset image64 = ImageReadBase64("#file_mime##postedXMLRoot.objbase64.XmlText#")>
<cfset ramfile = "ram://" & postedXMLRoot.objname.XmlText>
<cfimage action="write" source="#image64#" destination="#ramfile#" overwrite="true">
<cffile action="readbinary" file="#ramfile#" variable="image_bin">
<cffile action="delete" file="#ramfile#">
<cfquery name="InsertImage" datasource="#datasource#">
INSERT INTO test_images
image_blob
SELECT
<cfqueryparam value="#image_bin#" cfsqltype="CF_SQL_BLOB">
FROM dual
</cfquery>Can't you use "alter index <shema.spatial_index_name> rebuild ONLINE" ? Thanks. I could switch to "rebuild ONLINE" and see if that helps. Are there any potential adverse effects going forward, e.g. significantly longer rebuild than not using the ONLINE keyword, etc? Also wondering if spatial index operations (index type = DOMAIN) obey all the typical things you'd expect with "regular" indexes, e.g. B-TREE, etc.
-
Oracle error ORA-604 when opening a connection
I am facing an issue with my WCF service which is using ODP.NET version 4.112.2.0(x64) and Oracle 11g.
The service runs without any problems on the test servers but on production server (Windows 2008 R2) when an attempt is made to call any service method it fails with the following Oracle error code Ora-604. the message is
ORA-604: error occurred at recursive SQL level %s
The exception is thrown when a call to meethod Open is made to open a connection.
There is no inner exception. So far I have tried checking the connection string, the user permissions and setting the TNS_ADMIN environment variable but nothing has worked.
Another thing to mention is that another WCF service which uses some of the same stored procedure I am using is working fine on the same server.
Has anyone seen this before?
Thanks,
ADo you have a login trigger?
select * from dba_triggers where triggering_event like 'LOGON%'
If so, try disabling it.
Does the working service use the same credentials as this problem service?
Are you able to connect using sqlplus, with the same credentials from the same client to the same database? If it's not an ODP.NET specific problem, the dba guys might be able to help better: General Database Discussions
Greg -
Is there a listing or book of oracle error codes?
i am looking for a book of oracle error codes. Is there someplae where I can find them online or anywhere really.
thanksSee the following URL gives you a list of oracle messages and actions to be done
http://ora-doc.cict.fr:7777/server.815/a67785/toc.htm
Maybe you are looking for
-
Changing marker size horizontally?
How does one increase the horizontal size of a marker? I have my song labeled with colored markers for easy visual reference (I am visually impaired) but would like to see them better, especially from a distance. For the life of me I can't find it in
-
Can I pre-set the cropping tool so that the final image will fit correctly on a specific size of paper? For example, if I plan to print an image on 8x10 photo paper, I want the cropping tool to maintain the 8x10 ratio no matter how large or small I m
-
Why if my icloud info is the same as my itunes login and password does it say the account name or password is incorrect
-
ABAP version error of sneak preview
hi all, I am trying to install ABAP version in the sneak preview and this is the error i get at step 5 of 17 please help. Thanks Pradeep ERROR 2005-11-21 03:10:20 MOS-01021 PROBLEM: C:/DOCUME1/PRADEE1/LOCALS~1/Temp/sapinst_exe.5476.1132538565\sapc
-
Unable to download 8.0.1 update
I'm unable to download the update using the update manager in Premiere 8.0. I get an error message "The update server is not responding, which means it may be offline at the moment or the internet or firewall settings may be incorrect." I tried multi