How retrieve the statement error

Hi,
When an oracle error occurs beyond to retrieve the Error Code and Error Message with SQLCODE and SQLERRM, I'd like to retrieve also the statement that produces this error.
For example:
CREATE TABLE TAB1
ID NUMBER,
NAME VARCHAR2(32 BYTE)
CREATE TABLE TAB2
ID NUMBER,
NAME VARCHAR2(32 BYTE)
CREATE TABLE LOG_ERROR
OBJ_NAME VARCHAR2(50 BYTE),
ERR_CODE NUMBER,
ERR_MSG VARCHAR2(500 BYTE),
STM_MSG VARCHAR2(1000 BYTE)
I've this trigger:
CREATE OR REPLACE TRIGGER MY_TRG
BEFORE INSERT ON TAB1
FOR EACH ROW
DECLARE
ERR_NUM     NUMBER;
ERR_MSG     VARCHAR2(300);
BEGIN
IF :NEW.ID=3 THEN
INSERT INTO TAB2 (ID, NAME) VALUES ('AAA', 5555);
END IF;
IF :NEW.ID = 7 THEN
INSERT INTO TAB2 (ID, NAME) VALUES ('BBBB','7777');
END IF;
EXCEPTION
WHEN OTHERS THEN
     ERR_MSG:= SUBSTR(SQLERRM, 1, 300);
     ERR_NUM:= SQLCODE;
     INSERT INTO LOG_ERROR (OBJ_NAME, ERR_CODE, ERR_MSG)
VALUES ('MY_TRG', ERR_NUM, ERR_MSG);
END MY_TRG;
When I RUN:
INSERT INTO TAB1 (ID, NAME) VALUES (3, 'MY_NAME');
COMMIT;
I get this error in LOG_ERROR table:
OBJ_NAME.............ERR_CODE...............ERR_MSG.....................STM_MSG
MY_TRG...............-1722..............ORA-01722: invalid number.............
INSERT INTO TAB1 (ID, NAME) VALUES (7, 'YOUR_NAME');
COMMIT;
I get same error in LOG_ERROR table:
OBJ_NAME.............ERR_CODE...............ERR_MSG.....................STM_MSG
MY_TRG...............-1722..............ORA-01722: invalid number.............
I'd like to get:
INSERT INTO TAB1 (ID, NAME) VALUES (3, 'MY_NAME');
COMMIT;
OBJ_NAME.............ERR_CODE...............ERR_MSG..........................STM_MSG
MY_TRG...............-1722..............ORA-01722: invalid number.......INSERT INTO TAB2 (ID, NAME) VALUES ('AAA', 5555)
INSERT INTO TAB1 (ID, NAME) VALUES (7, 'YOUR_NAME');
COMMIT;
OBJ_NAME.............ERR_CODE...............ERR_MSG........................STM_MSG
MY_TRG...............-1722..............ORA-01722: invalid number.......INSERT INTO TAB2 (ID, NAME) VALUES ('BBBB','7777')
How can I retrieve the statement that produces this error in the STM_MSG column?
Thanks in advance!

Error occured due to ID is number type and you are inserting Char in the insert statement. May it looks like you want to swap the values in the insert.
To track the error event may be this?
Modify erro table and add column Event varchar2(200);
theni sert the ven in to error_log table for the error at each event. somthing like this
CREATE OR REPLACE TRIGGER MY_TRG
BEFORE INSERT ON TAB1
FOR EACH ROW
DECLARE
ERR_NUM NUMBER;
ERR_MSG VARCHAR2(300);
lEvent varchar2(200);
BEGIN
IF :NEW.ID=3 THEN
  lEvent:=' Inserting in to tab2 for id 3';
  INSERT INTO TAB2 (ID, NAME) VALUES ('AAA', 5555);
END IF;
IF :NEW.ID = 7 THEN
  lEvent:=' Inserting in to tab2 for id 7';
  INSERT INTO TAB2 (ID, NAME) VALUES ('BBBB','7777');
END IF;
EXCEPTION
WHEN OTHERS THEN
   ERR_MSG:= SUBSTR(SQLERRM, 1, 300);
   ERR_NUM:= SQLCODE;
   INSERT INTO LOG_ERROR (OBJ_NAME, ERR_CODE, ERR_MSG,event)
    VALUES ('MY_TRG', ERR_NUM, ERR_MSG,lEvent);
END MY_TRG;formatted
Message was edited by:
devmiral

Similar Messages

  • TS3297 How is the following error corrected when trying to access the Itunes store - an unkown error occurred There was an error in the Itunes store. Please try later Ox80092013

    How can the following error incurred when trying to access the Itunes Store be corrected:  an unknown error occurred  There was an error in the store. Please try later 0x80092013

    Try here  >  http://support.apple.com/kb/TS3221
    And/or... see the  More Like This  section on the right.

  • How create the SMQ2 error through program ?

    Hi all,
    How create the SMQ2 error through program ?
    Any idea ... plsease share.
    Regards,
    Srikanth

    Hi juturusrikanth ,
    which one is the SMQ2 error?
    [FAQ's, intros and memorable discussions in the ABAP General Forum|FAQ's, intros and memorable discussions in the ABAP General Forum;
    [How to post code in SCN, and some things NOT to do...|How to post code in SCN, and some things NOT to do...;
    Regards
    Clemens

  • How retrieving the product key for a SQL Server 2005 installation

    Hi,
    is it possible to retrieve the product key associated to a SQL Server 2005 installation?
    If yes, how?
    Many thanks

    Hello,
    The following tool may provide you the product key for SQL Server 2005 and SQL Server 2008 instances.
    http://www.nirsoft.net/utils/product_cd_key_viewer.html
    Hope this helps.
    Regards,
    Alberto Morillo
    SQLCoffee.com

  • How received the following error message:  iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows error 998).  I did what was requested and reinstalled iTunes, but still get this error message.  Help!

    My Toshiba laptop just recently started showing the the following error message when I try to open iTunes: " iTunes was not installed correctly. Please reinstall iTunes. Error 7 (Windows error 998)".  I did what was requested and reinstalled iTunes, but still get this error message.  Help!

    b noir I never got any message about an entry point
    Many thanks. If we're looking at a "naked" Error 7, I'd start with box two in the following user tip:
    Troubleshooting issues with iTunes for Windows updates

  • How about the statement of regular expression like for this

    I what to get varians String array by one regular express for the statement like:
    ${user} like play ${game} in ${date}
    I want to get String[] as {"user","game","date"} by one regex, by str.split(regex). I tried many times but always fail to get the result I expected. May it be possible to meet the destination?
    thanks in advance
    Frederick

    why StringBuffer was using here?So one could split the pattern into multiple lines. But it just occurred to me that one could just use string concatenation, which would look better. I don't know why I bothered to use StringBuffefer.
    e.g.:
    String pattern =
        "^" +           // the start of a string
        "(dog)|(cat)" + // match either "dog" or "cat" at the start of the line
        "\\s*" +        // match an arbitrary amount of whitespace
        "$";            // but don't allow anything other than whitespace after dog or cat
    Pattern p = Pattern.compile(pattern);
    Pattern p = Pattern.compile("^(dog)|(cat)\\s*$");> isn't this look more simpler and better?
    In this case, yes. I was looking for a way to make regexps more explicit, with whitespace and comments, for more complicated cases.
    But those double quotes and plus signs add ugliness of their own, so a regexp would have to be pretty complex before it would be an improvement.

  • Dose any one know how fix the following error

    hi i just updated the softwear on my i pad and now it wont let me read any of my books
    it just keeps showing this error message ( this page contains the following errors: error on line 3 at column 1: Extra content at the end of the document error on line3 at column 1:encoding error Below is a rendering of the page up to the first error) can some one help !

    @easydoweb
    This resource has probably not been updated to take account of Belle http://www.nokia.com/gb-en/support/troubleshooting/?action=singleFAQ&caseid=FA134387_en_US but can't you get your network provider to resend "Settings" SMS?
    Happy to have helped forum with a Support Ratio = 42.5

  • IDOC_INPUT_ORDER - How manage the custom error message ?

    Hello,
    on EXIT_SAPLVEDA_002 and EXIT_SAPLVEDA_003 I done some custom check, (I would show some custom message as a result of these check).
    My question is: How to show these custom message on the standardc idoc spool (WE02) ??
    There's DERRTAB internal table to manage the error, but is not available on there exit ...(EXIT_SAPLVEDA_002 and 3)
    Any idea ??
    thank you

    Hello,
    question is if you want to raise an error, which makes sense only if the document is not posted or just an information message.
    Please consider that you can put messages into the idoc only connected with a status. If you set status 51 thge Idoc is reprocessible, if you set status 53 it is successfully processed.
    In error case you can raise exception USER_ERROR. in exit EXIT_SAPLVEDA_002. Set SY-MSGTY, SY-MSGID, SY-MSGNO, etc before. In exit EXIT_SAPLVEDA_003 you can set changing parameter ok to space. Then SAP will add an error message.
    /Michael

  • How get the state of server

    How can I know whether one server is runnig through the java program?

    Hi,
    Try to run following WLST command
    username = 'weblogic'
    password = 'weblogic'
    URL='t3://localhost:8001'
    connect(username,password,URL)
    domainRuntime()
    cd('ServerRuntimes')
    servers=domainRuntimeService.getServerRuntimes()
    for server in servers:
    print ' SERVER NAME : ',server.getName();
    print ' SERVER STATE :', server.getState()
    print ' SERVER LISTEN ADDRESS : ', server.getListenAddress()
    print ' SERVER LISTEN PORT : ', server.getListenPort()
    print ' SERVER HEALTH STATE :', server.getHealthState()
    Regards,
    Kal

  • TS1424 how about "the connection error. The game server had an internal error. please try again later". thats what happen to me while i want to purchase a gem in dragonvale aplication and i being charged for the Gem that i never had.

    regarding of the game that I playing, its Dragonvale, I plan to buy a Gem. and after I desided to buy, but what happen is that the game centre it self didnt gave me the Gem but instead they said "Connection Error. The Game server had an internal error. Please try again later."
    so if thats the case of error transaction..so why the BACKFLIP STUDIOS(DragonVale) charged me to my credit card for the Gem that I never received.
    I need to clear this things.

    regarding of the game that I playing, its Dragonvale, I plan to buy a Gem. and after I desided to buy, but what happen is that the game centre it self didnt gave me the Gem but instead they said "Connection Error. The Game server had an internal error. Please try again later."
    so if thats the case of error transaction..so why the BACKFLIP STUDIOS(DragonVale) charged me to my credit card for the Gem that I never received.
    I need to clear this things.

  • How retrieve the document after having added worksheets, logos and formula

    Hi folks
    IHAC in R12 which need to add worksheets, logos and formulas to web ADI interface. This has been done, so he wants to be able to retrieve this modified file when download the web ADI interface from the system.
    Any tips and / or documentation are welcome
    Regards
    Richard

    I dont think this can be done.

  • How can the state of 1 item affect the state of another?

    Hi there,
    I am trying to make it so when you mouse over a text box, the box behind it changes colour.
    Is there any way that a rollover on a textbox can change the colour of another box?
    Many thanks,
    Rory

    Hi there,
    I am trying to make it so when you mouse over a text box, the box behind it changes colour.
    Is there any way that a rollover on a textbox can change the colour of another box?
    Many thanks,
    Rory

  • Retrieve Specific Mapping Error Information Within BPM Flow.

    I have an Integration Process which executes a message mapping step prior to further processing. When the message mapping receives an error there is an exception branch
    within the process that will send an email using the Mail Receiver Adapter. The mail message prototcol is XIALL which sends the payload and soap envelope.
    However, I need to retrieve the actual error returned from the mapping step and forward that specific information to the originator of the failed message as an email.
    I know we can use the alert functions to send alerts, but my requirement is to send the actual error via email to our external vendors / customers.
    Has anyone had success doing this?

    Hi, have you got it done? Please share!
    Thanks,
    Karthik

  • How to retrieve SQL statement in the CR 2008

    I'm using Crystal Reports 2008 in MS Visual Studio 2008, how can i retrieve SQL statement from *.rpt file, i have tried this code, but it doesn't work:
    ReportDocument rdReport = new ReportDocument();
    rdReport.Load("Reports/EmployeeTest.rpt", OpenReportMethod.OpenReportByTempCopy);
    CrystalDecisions.ReportAppServer.Controllers.RowsetController rsController;
    CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rdClient = rdReport.ReportClientDocument; // on this line it throws an exception "The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."
    CrystalDecisions.ReportAppServer.DataDefModel.ISCRGroupPath rdGroupPath = new CrystalDecisions.ReportAppServer.DataDefModel.GroupPath();
    string temp;
    string sql;
    rsController = rdClient.RowsetController;
    sql = rsController.GetSQLStatement(rdGroupPath, out temp);
    maybe i'm doing something wrong ?
    thanks

    Hello Ludek,
    when I try to get the report from the session I got an error like this (I am using State Server Session mode i.e out proc in my application)
    ReportClientDocument     'reportDocument.ReportClientDocument' threw an exception of type 'System.InvalidOperationException'     CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument {System.InvalidOperationException}
    +base     {"The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."}     System.SystemException {System.InvalidOperationException}
    StackTrace     "   at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ReportClientDocument()"     string
    so is it the problem of not opened with RAS. Does installation of RAS solves the problem, If so Is it a free-ware or needs to be purchased.
    Ashok

  • Error: The report source could not be retrieved from the state object.

    I have been trying to create a report in a JSF page. The relevant parts are below:
    Inside the JSP page, this is the code:
                  <jsp:useBean id="MyBean" class="com.nm.facade.rto.POJOViewerBean" scope="session" />
                    <jsp:setProperty name="MyBean" property="reportLocation" value="Report1.rpt" />
                   <v:reportPageViewer reportSource="#{MyBean.reportSource}"
                                           displayToolbarPrintButton="true"
                                           printMode="ActiveX"
                                           zoomPercentage="100"
                                           displayToolbarExportButton="true"
                                           displayToolbarRefreshButton="true"
                                           viewerName="My Viewer"
                   ></v:reportPageViewer>
    In the backing bean, this is the relevant code:
        public Object getReportSource() throws ReportSDKException
            if (propertiesChanged || reportSource == null)
                propertiesChanged = false;
                if (reportLocation == null)
                    throw new RuntimeException("The reportLocation property must be set before a report source is retrieved");
                ReportClientDocument rcd = new ReportClientDocument();
                rcd.setReportAppServer(ReportClientDocument.inprocConnectionString);
                rcd.open(reportLocation, 0);
                DatabaseController dbc = rcd.getDatabaseController();
                //Create the POJO collection and populate it with data
                ReportData[] data =
                  new ReportData("B.B.", "King", 6, new Date(25, 9, 16)),
                    new ReportData("Muddy", "Waters", 7, new Date(15, 4, 4)),
                    new ReportData("John Lee", "Hooker", 8, new Date(16, 8, 16)),
                    new ReportData("Otis", "Rush", 9, new Date(34, 4, 29)),
                    new ReportData("Buddy", "Guy", 10, new Date(36, 7, 30))
                //Create the result set from the collection of POJOs
                POJOResultSetFactory factory = new POJOResultSetFactory(ReportData.class);
                factory.setVerbose(true);
                POJOResultSet results = factory.createResultSet(data);
                ResultSetMetaData metaData = results.getMetaData();
                //Set the resultset as the report datasource
                      //Get the table name from the 'Set Datasource Location' dialog in the Crystal Reports designer
                String reportTable = "getReportDataDataSource";
                dbc.setDataSource(results, reportTable, reportTable);       
                IReportSource reportSource = rcd.getReportSource();
                if (reportSource == null)
                    throw new RuntimeException("Unable to get a report source.");
            return reportSource;
    In the CRConfig.xml, this is what is there:
    <?xml version="1.0" encoding="utf-8"?>
    <CrystalReportEngine-configuration>
        <reportlocation>../reports</reportlocation>
        <timeout>0</timeout>
        <ExternalFunctionLibraryClassNames>
             <classname></classname>
        </ExternalFunctionLibraryClassNames>
    </CrystalReportEngine-configuration>
    The report template 'Report1.rpt' is packaged under WEB-INF/reports in the war file.
    When I try to generate the report by accessing the JSF page, I am getting an error: "The report source could not be retrieved from the state object. "
    I am not sure what is wrong. Can someone help me in resolving this issue?
    Edited by: renshai on Jul 9, 2009 3:21 AM

    My formatting gets lost and the message looks unintelligible. After some experimentation, I found that if the message exceeds some length, the formatting is removed. Since I couldn't find any way to delete this post, I made another post with the same subject. Please ignore this post and help me to find a solution for the problem posted in the other thread with the same subject. Thanks in advance.

Maybe you are looking for

  • Line items seen in fbln but not in process open items

    Hi Gurus, one line item is seen in fbl3n but not in process open items in f-07, the entry is rent a/c Dr                      to rent payable a/c we can see is fb03, fbl3n of both accounts Pl suggest. I am unable to clear

  • Can't eject

    I have my Ipod setup for manual sync and when i try to eject it itunes says it can't eject the ipod becuase it containes files that are inuse by another application. What am i doing wrong and how do i fix it please help. Dell XPS 410   Windows XP  

  • Failed to install solaris on new "Sun Fire V100"

    Hi All, I'm new to solaris. I have a new server Sun Fire v100. Just after power on the server I got a following message on the console screen *" No memory Detected! Cannot proceed further !!!"* Actually I want to install solaris 10 update 4 on this s

  • I cannot login to Creative Cloud. It logs me out immediately.

    Whenever I try to log into Creative Cloud, I get the message that "You've been signed out". Any ideas?

  • MacPro Even though I unblock pop ups in security they are still blocked

    In Spanish ( this is how works my system) POP ups call emerging windows (Ventanas Emergentes). Once I blocked on the area Safari- preferences- security this line, however once I got back to this and unblocked it, now happens to be blocked no matter t