Solved

How to use a TRY CATCH in Sybase SQL syntax. Or something similar?

Posted on 2016-07-18
1
199 Views
Last Modified: 2016-07-19
Hello Sybase Experts. I am porting some SQL Server sql to Sybase sql. The SQL Server sql uses several TRY CATCH blocks in sql server.
Is there any similar type of structure in Sybase to handle exceptions? If so, can someone show me how to do it?
BEGIN TRY
   EXEC (@spName)
END TRY
BEGIN CATCH
     -- Recovery code goes here

END CATCH
0
Comment
Question by:brgdotnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
BudDurland earned 500 total points
ID: 41719979
You didn't mention which version of Sybase, but it should pretty much be the same.  Here's a sample from the SQLAnywhere docs.  It puts the value 6 in the table 't'

BEGIN TRY
    DECLARE val INT;

    SET val = 0;

    INSERT INTO t VALUES( 1 / val );
    -- This statement will not be executed
    INSERT INTO t VALUES( val );
END TRY
BEGIN CATCH
    SET val = 6;
    INSERT INTO t VALUES( val );
END CATCH;

Open in new window

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This article outlines some of the reasons why an email message gets flagged as spam on a recipient's end.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question