Solved

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

Posted on 2016-07-18
1
55 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
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
A procedure for exporting installed hotfix details of remote computers using powershell
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now