Error handling not available with linked servers

Hello,
I have a stored procedure which inserts data to a linked mysql Server. The table in mysql has a unique key and I try to insert a new record with a conflicting key.
My problem is that I am not able to do an error handling because my script stops immediatly when the error in the SP occurs.
The error message itself is ok. But why is the script cancelled? So I don't have a possibility to do some error handling. I am working against SQL Server 2000. No TRY CATCH is available.
Here is my code:
DECLARE @RC int
DECLARE @ItemNr nvarchar(255)
DECLARE @Hostname nvarchar(255)
DECLARE @IpAdresse nvarchar(255)
DECLARE @LogLevel int
DECLARE @Message nvarchar(1000)
DECLARE @LocalError int
-- Error handling is working as expected
PRINT 1/0
SELECT @LocalError=@@ERROR
IF @LocalError<>0
 PRINT 'Error'
ELSE
 PRINT 'Success'
SELECT @ItemNr='AN12326m', @Hostname='hostname' ,@IpAdresse='ipadresse', @LogLevel=99, @Message='Test', @RC=0
-- Error handling does not work
EXECUTE [Asset].[dbo].[p_kapaya_DbSync_InsertMySqlRecord]
   @AssetNr, @Hostname, @IpAdresse, @LogLevel, @Message OUTPUT, @RC OUTPUT
-- The following code is not reached, when an error occurs because the execution of the script is cancelled
SELECT @LocalError=@@ERROR
IF @LocalError <>0
 PRINT @LocalError
ELSE
 PRINT 'Success'
Error Message
Der OLE DB-Anbieter 'MSDASQL' für den Verbindungsserver 'MySQL' hat die Meldung '[MySQL][ODBC 5.1 Driver][mysqld-5.0.67-community-nt]Duplicate entry 'AN12326m' for key 1' zurückgeben.
Meldung 7343, Ebene 16, Status 2, Prozedur p_kapaya_DbSync_InsertMySQLRecord, Zeile 57
Der OLE DB-Anbieter 'MSDASQL' für den Verbindungsserver 'MySQL' konnte INSERT INTO für die [MSDASQL]-Tabelle nicht ausführen.
Kind regards
Patrick

This is not unique to linked servers. When an error occurs, there are several actions that SQL Server can take. It can abort the batch, it can abort the current scope or it can just termintate the current statement. Any active transaction may or may not
be rolled back. And this is not all.
Which of these actions, SQL Server takes it is hard to predict, becuase the developers have to have rolled a dice on deciding which action to take. Although, if you have SET XACT_ABORT ON, it is more consistent: in this case, most errors aborts the batch
and rolls back the transaction.
To trap the error, you need to use TRY-CATCH which permits you to trap most (not all) errors. See here for a quick introduction:
http://www.sommarskog.se/error_handling_2005.html
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • 3.2 to 4.1 Upgrade - Error Handling for Unavailable Database Links

    Hi,
    I'm having a 3.2 -> 4.1 upgrade issue related to error handling for failed database links.
    I have a conditional Exists button on a page that has a SQL query to linked tables. However, for the 10 minutes every day where the target of the database link is getting a cold backup, the query fails. In the old 3.2 apex I simply got an error inside the region where the button is located but otherwise the page was still visible:
    "Invalid exists/not exists condition: ORA-02068: following severe error from MYDBLINK ORA-01034: ORACLE not available ORA-27101: shared memory realm does not exist"
    However, in apex 4.1.0.00.32 I get the following unhandled error, and clicking "OK" takes me to the edit page when logged in as developer.
    i.e., the page can't be run at all while the database links are failing in this one region.
    Error Error processing condition.
    ORA-12518: TNS:listener could not hand off client connection
    Technical Info (only visible for developers):
    is_internal_error: true
    apex_error_code: APEX.CONDITION.UNHANDLED_ERROR
    ora_sqlcode: -12518
    ora_sqlerrm: ORA-12518: TNS:listener could not hand off client connection
    component.type: APEX_APPLICATION_PAGE_REGIONS
    component.id: 4
    component.name: Current Alerts
    error_backtrace:
    ORA-06512: at "SYS.WWV_DBMS_SQL", line 1041
    ORA-06512: at "APEX_040100.WWV_FLOW_DYNAMIC_EXEC", line 687
    ORA-06512: at "APEX_040100.WWV_FLOW_CONDITIONS", line 272
    General users see this:
    Error Error processing condition.
    ORA-01034: ORACLE not available ORA-02063: preceding line from MYDBLINK
    clicking "OK" takes user to another page, not sure how apex decides which, but not a concern at the moment.
    I've done a search and read the page http://www.inside-oracle-apex.com/apex-4-1-error-handling-improvements-part-1/ but the new apex error handling isn't clear to me, and I don't know if the apex_error_handling_example provided on that page would be applicable to this situation.

    Thanks Patrick.
    The PL/SQL Function Body returning boolean condition with:
    begin
        for l_check in (
          SELECT 1
           FROM myview@MYDBLINK
          WHERE ... ) loop
            return true;
        end loop;
        return false;
    exception when others then
        sys.htp.p('Invalid exists/not exists condition: ' || sys.htf.escape_sc(sqlerrm));
        return false;
    end; Resulted in a similar issue:
    Error Error processing condition.
    ORA-04052: error occurred when looking up remote object MYLINKUSER.myview@MYDBLINK
    ORA-00604: error occurred at recursive SQL level 3
    ORA-01033: ORACLE initialization or shutdown in progress
    ORA-02063: preceding line from MYDBLINK
      Technical Info (only visible for developers)
    is_internal_error: true
    apex_error_code: APEX.CONDITION.UNHANDLED_ERROR
    ora_sqlcode: -4052
    ora_sqlerrm: ORA-04052: error occurred when looking up remote object MYLINKUSER.myview@MYDBLINK
    ORA-00604: error occurred at recursive SQL level 3
    ORA-01033: ORACLE initialization or shutdown in progress
    ORA-02063: preceding line from MYDBLINK
    component.type: APEX_APPLICATION_PAGE_REGIONS
    component.id: 4
    component.name: Current Alerts
    error_backtrace:
    ORA-06512: at "SYS.WWV_DBMS_SQL", line 904
    ORA-06512: at "APEX_040100.WWV_FLOW_DYNAMIC_EXEC", line 588
    ORA-06512: at "APEX_040100.WWV_FLOW_CONDITIONS", line 148However, I created a view with the same query:
    CREATE OR REPLACE VIEW v_localview (ALERT_1)
    AS
    SELECT 1
      FROM myview@MYDBLINK ...then change the condition to look at the local view:
    begin
        for l_check in (
          select alert_1 from v_localview ) loop
            return true;
        end loop;
        return false;
    exception when others then
        sys.htp.p('Invalid exists/not exists condition: ' || sys.htf.escape_sc(sqlerrm));
        return false;
    end;As a view is simply a query I'm surprised this should make any difference but it now looks similar to the 3.2 error, inside the region, when the linked database gets its morning cold backup, and this is fine:
    Invalid exists/not exists condition: ORA-12518: TNS:listener could not hand off client connection

  • Livecache lock handler not available in APO

    Hello Experts,
    We are getting the error "Livecache lock handler not available" error when we are running planning jobs in SAP APO.
    We are using parallel processing profiles for DP background processing jobs (Macro calculations) and I am getting this error only when a job is run with PP profile.
    Below are the parameters of the parallel processing profiles:
    Application: DP background processing
    No of parallel processes: 2
    Block Size: 500
    The error message is written in the spool generated for the background job and the job fails. Eventually the process chain fails in which the job is included.
    Please provide some pointers if anyone has come across the same error.
    Regards,
    Raghu

    Hi JB,
    Thanks for the note, Basis check the solution in the note and system seems to have met the requirements.
    But one thing is likely to increase the MaxSQLLocks in the system as the demand of the locks is more than the availability. So basis is looking at this dimension to increase the number of locks in the system.
    Will update soon in case of any conclusion.
    Regards,
    Raghu

  • Portlet gives ERROR: Content not available and log says FileNotFoundExcepti

    I'm trying to deploy my 'works on JBoss' portlets onto portlet server 7.2
    I uses psadmin register-portlets... to load my ear file with the portlets
    I went into 'Add New Channel or Container' and picked the sandbox and 'channel'
    Step 1.1 I picked JSR 168 or 268
    Step 2 I could see my portlets in the drop down so I picked one
    That seemed to work fine.
    Then I went into 'design desktop layout' and I picked my portlet from the list there and put it onto the sandbox
    Looking good. There were some odd warning errors in the log referring to JSF which don't look relevant so I ignored them (see below)
    Next I logged into sanbox and all I see are two frames (I added two portlets) both saying ERROR: Content not available
    In my log I have two identical errors:
    2008-11-21T17:17:35.875+1300|SEVERE|sun-appserver9.1|javax.enterprise.system.container.web|_ThreadID=33;_ThreadName=com.sun.portal.desktop.context.ReusableProviderCaller;_RequestID=2cb012a6-0fbc-498a-9ecd-02efae5c854a;|ApplicationDispatcher[] PWC1231: Servlet.service() for servlet default threw exception
    java.io.FileNotFoundException: /servlet/PortletAppEngineServlet
         at org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:732)
         at org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:384)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:718)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
         at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
         at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:855)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:703)
         at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:660)
         at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:578)
         at com.sun.portal.portletcontainer.impl.PortletContainer.invokePAE(PortletContainer.java:790)
         at com.sun.portal.portletcontainer.impl.PortletContainer.invokePAE(PortletContainer.java:673)
         at com.sun.portal.portletcontainer.impl.PortletContainer.getMarkup(PortletContainer.java:209)
         at com.sun.portal.providers.window.WindowProvider.getPortletContent(WindowProvider.java:382)
         at com.sun.portal.providers.window.WindowProvider.getContentInternal(WindowProvider.java:247)
         at com.sun.portal.providers.window.WindowProvider.getContent(WindowProvider.java:212)
         at com.sun.portal.providers.portletwindow.PortletWindowProvider.getContent(PortletWindowProvider.java:109)
         at com.sun.portal.desktop.context.ReusableProviderCaller.run(ReusableProviderCaller.java:206)Earlier in the log I can see:
    [#|2008-11-21T17:17:14.343+1300|WARNING|sun-appserver9.1|javax.enterprise.resource.webcontainer.jsf.application|_ThreadID=26;_ThreadName=httpSSLWorkerThread-8080-3;/faces/desktop/Library.jsp;/faces;_RequestID=eaa404b5-8589-4873-940e-4146d603277e;|JSF1015: Request path '/faces/desktop/Library.jsp' begins with one or more occurrences of the FacesServlet prefix path mapping '/faces'.|#]
    #|2008-11-21T17:28:18.453+1300|INFO|sun-appserver9.1|javax.enterprise.system.stream.out|_ThreadID=24;_ThreadName=httpSSLWorkerThread-8080-4;|
    com.sun.web.ui.component.DropDown::The current value of component frm:createChannel:step2:sheet2:section1:p2:providers does not match any of the selections.
    Did you forget to reset the value after changing the options? |#]Those don't mean anything to me but they look like the console is complaining about something internal.
    Where did I go wrong here? I did not deploy the ear file normally, just ran the psadmin. Do I need to do both? Is there some other step I missed?
    Thanks for any help

    As you can see from docs - http://docs.sun.com/app/docs/doc/820-2052/gdela register-portlet is supported for EAR files generated by JCAPS tools. In you case you need to manually add the portal required artifacts. In case of WAR this is handled by deploy-portlet command. I don't remember exact artifacts that were added in PS7.2 portlet deployment. You can deploy a WAR and see the artifacts that will be added and the entry in web.xml as well.
    Regards,
    Deepak

  • Live cache lock handler not available

    Hi we are frequently getting this error Live cache lock handler not available and this causes our process chains to fail.
    Can anyone please explain in details what this error refers to and direct to any good links for error resolution.

    Hello,
    1. As SAP customer, you could create the SAP message to the component BC-DB-LCA and get SAP support.
    2. If you set the flag 'activate livecache lock' in tcode /SAPAPO/MSDP_ADMIN for your planning area on SCM system, please run the connection test for the LEA connection in /ndb59 to check the LEA connection settings.
       The liveCache installation guide has additional information about LEA connection.
    Regards, Natalia Khlopina

  • Livecache lock handler not available

    Hello Experts,
    We are getting the error "Livecache lock handler not available" error when we are running planning jobs in SAP APO.
    We are using parallel processing profiles for DP background processing jobs (Macro calculations) and I am getting this error only when a job is run with PP profile.
    Below are the parameters of the parallel processing profiles:
    Application: DP background processing
    No of parallel processes: 2
    Block Size: 500
    The error message is written in the spool generated for the background job and the job fails. Eventually the process chain fails in which the job is included.
    Please provide some pointers if anyone has come across the same error.
    Regards,
    Raghu

    Hi JB,
    Thanks for the note, Basis check the solution in the note and system seems to have met the requirements.
    But one thing is likely to increase the MaxSQLLocks in the system as the demand of the locks is more than the availability. So basis is looking at this dimension to increase the number of locks in the system.
    Will update soon in case of any conclusion.
    Regards,
    Raghu

  • Saving master page in search template throws error "UserAgent not available, file operations may not be optimized"

    Hi Folks,
    I was trying to save basic search template master page "seattle.master" after making change to the template.
    I have added just "CompanyName" folder and update the line below in seattle.master.
    Change is this : <SharePoint:CssRegistration Name="Themable/CompanyName/corev15.css" runat="server"/>
    When I save it, and refresh page on browser, it shows "Something went wrong" error.
    ULS says the following error : "UserAgent not Available, file operation may not be optimized"
    Pls let us know if there is a solution.
    Any help Much appreciated !
    Thanks,
    Sal
    

    Hi Salman,
    Thanks for posting this issue, 
    Just remove this below given tag and check out. It might be happened that your control is conflicting with others. 
    Also, browse the below mentioned URL for more details
    http://social.msdn.microsoft.com/Forums/office/en-US/b32d1968-81f1-42cd-8f45-798406896335/how-apply-custom-master-page-to-performance-point-dashboard-useragent-not-available-file?forum=sharepointcustomization
    I hope this is helpful to you. If this works, Please mark it as Answered.
    Regards,
    Dharmendra Singh (MCPD-EA | MCTS)
    Blog : http://sharepoint-community.net/profile/DharmendraSingh

  • Script Error : Handler Not Definied

    Hi Gurus,
    I try to play a Lingo Script with Director MX 2004 but i got
    this message: Script Error : Handler Not Definied
    The Debug stops at this line in my code: dosRegister
    "70BE7B1-13977F4"
    Is anything missing from my Xtras folder?
    I have DirectOS though.
    Any idea ??
    Thx

    I suspect you have a cast member that uses one of the three
    names in the
    list and it is not a check box. It's probably before the
    actual checkbox
    member in the cast so it's finding it first.
    Craig Wollman
    Lingo Specialist
    Word of Mouth Productions
    212-928-9581
    www.wordofmouthpros.com
    "ajrobson" <[email protected]> wrote in
    message
    news:etn9j1$op2$[email protected]..
    >I have a script that get a list of choosen check boxes,
    it was working fine
    >but
    > now when i press the button that calls the script i get
    a error saying
    > "script
    > error property not found" then it lists the line i have
    put a * next to
    > and
    > says #hilite
    >
    > This is the top part of that script and to my knowlegde
    i have not chnaged
    > any
    > of it and it worked before but now it does not, i also
    use a script almost
    > identical to this but use it for radiobuttons instead
    and the line is the
    > same
    > in that and that script works, can anybody tell me what
    as gone wrong?
    >
    >
    >
    > global err
    >
    > on CheckBoxState -- name of custom handler
    > TickedBoxes = [] -- a empty list will be filled where
    ever a checkbox is
    > ticked
    > CheckBoxNames = ["Dr no", "From russia with
    love","Casino royale" ]
    > repeat with i = 1 to 3 -- repeat for each checkbox
    > CurrentCheckbox = CheckBoxNames
    > ** if the hilite of member(CurrentCheckbox) then -- if
    currentcheckbox
    > hilite
    > is true (checked)...
    > append(TickedBoxes,CurrentCheckbox )
    > end if
    > end repeat
    > return TickedBoxes
    > end
    >

  • Allignment tool not available with the Student Version?

    Is the Allignment tool not available with the Student Version? It appears to be clickable yet no action… Is there a preference I'm missing?

    Shawn,
    Educational is a full version.
    You need to select (at least) two objects, then apply the deired Align operation(s).
    If something is really wrong, you may have a look at the list below.
    The following is a general list of things you may try when the issue is not in a specific file (you may have tried/done some of them already); 1) and 2) are the easy ones for temporary strangenesses, and 3) and 4) are specifically aimed at possibly corrupt preferences); 5) is a list in itself, and 6) is the last resort.
    2) Restart the computer (you may do that up to 3 times);
    3) Close down Illy and press Ctrl+Alt+Shift/Cmd+Option+Shift during startup (easy but irreversible);
    4) Move the folder (follow the link with that name) with Illy closed (more tedious but also more thorough and reversible);
    5) Look through and try out the relevant among the Other options (follow the link with that name, Item 7) is a list of usual suspects among other applications that may disturb and confuse Illy, Item 15) applies to CC, CS6, and maybe CS5);
    Even more seriously, you may:
    6) Uninstall, run the Cleaner Tool (if you have CS3/CS4/CS5/CS6/CC), and reinstall.
    http://www.adobe.com/support/contact/cscleanertool.html

  • I am using ipad mini ... I was unable to access facebook since long time... Its shows error could not communicate with the server.... I had install it but result was same. Can anyone help me???

    I am using ipad mini ... I was unable to access facebook since long time... Its shows error could not communicate with the server.... I had install it but result was same. Can anyone help me???

    first off , from the wired computer access the router using http://192.168.1.1 .. check the firmware version .. go to www.linksys.com/download and check the latest firmware available...if the router does not have the latest firmware , upgrade it first. .. after the firmware upgrade , reset and reconfigure the router
    if the router has the latest firmware , then reset the router for 30 seconds .. do a power cycle...access the router ui ..default password is admin..click on the "mac add clone" subtab , enable it and click clone....save the settings and do a power cycle..ensure that the wired computer is online
    on the router web ui , click on the wireless tab ..change the ssid - any non-linksys name , channel - 11 , security mode - wpa , beacon interval - 50 , fragmentation threshold - 2306 , RTS threshold - 2307 ..
    let me know if this helps you..

  • ...notifications are a paid only feature, they are not available with a free account...

    Hi Support-Team,
    is there a chance to change this:
    "... notifications are a paid only feature, they are not available with a free account ..."
    If we can't send a notification to an other user FormsCentral doesn't make sence and will cancel the account... That would be a pity, because otherwise everything would work very well.
    Kind regards
    Andreas

    Hi;
    Thanks for your feedback, but notifications are a paid feature and are not available in a free account.  That isn't likely to change.  Hopefully there is enough value in this and the other features of a paid account for you to consider an upgrade.
    Thanks,
    Josh

  • D7360 automatic duplex printing is not available with latest driver

    d7360 automatic duplex printing is not available with latest driver
    This question was solved.
    View Solution.

    Hello ephsh,
    Welcome to the HP Forums.
    I see that you are having an issue attempting to do some duplex printing.
    So I can better assist you, please respond with which Operating System you are running:
    Which Windows Operating System am I running?
    Mac OS X: How Do I Find Which Mac OS X Version Is on My Computer?
    I am going to attach a document that deals with a Two-Sided Print Option Is Not Available Even Though an Automatic Two-Sided Printing Accessory (Duple....
    Please feel free to write me back at your convenience.
    Cheers,  
    Click the “Kudos Thumbs Up" at the bottom of this post to say “Thanks” for helping!
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    W a t e r b o y 71
    I work on behalf of HP

  • . What is the error handling mechanism available in ODI ?

    What is the error handling mechanism available in ODI ?

    We have something called CKM in ODI. It provides option of Static control and Flow control.
    What you need to do is provide the proper constrains / validation rules on the source and target models. When you execute the interface , if any of the rule is violated , those rows goes to E$_ tables also called Error tables.
    Static control example :
    Before executing the interface , you can check the data health of your source model.
    Flow Control example :
    Thus for example you have 100 rows , out of which 10 rows violates the rule , then 90 rows will go to target table and 10 will go to error table. If you correct the values or modify the constraint and re execute the interface , those 10 rows will also go to target.
    Other than that if you mean Error handling in the package or load plan , you can use OK and KO appropriately and route the flow as per your requirement. This is all custom approach , which will vary from design to design.

  • Work Clearance Management  (WCM) not available with ECC 6.0

    Hi All,
    Work Clearance Management (WCM) is a part of SAP Plant Maintenance (PM). It is a standard functionality. This is not available with our installed version of ECC 6.0 system.
    The navigation should be
    SAP Easy Access > Logistics > Plant Maintenance > Work Clearance Management.
    This is also not available on SPRO.
    But whenever we directly enter the T Code related to WCM, it allows me to go to that screen. But if we want to customize the WCM using the same method then the SAP standard configuration is missing.
    I need to get this functionality available on our system.
    Is it a part of SAP software component SAP_APPL ?
    But how do I get this ?
    Can anyone pls help me on this ?
    Thanks and warm regards
    Purnendu

    I think that WCM it's present as an extension set (i'm not quite sure if is EA-PLM or EA-SCM). When you configure it, the activities related in custominizg, will appear as well.
    Hope this help
    Ezequiel

  • HT5622 Why do I get this massage undated is not available with this Apple ID

    Why do I get this massage update is not available with this Apple ID.

    There are dozens of posts with this same issue. Search before posting.
    It's an Apple issue;
    http://www.macrumors.com/2014/05/08/apple-id-ios-app-updates/

Maybe you are looking for