Tell RDBMS Intra SQL Transaction?

Trying to capture some sql server/sybase related research (minimal). I need to tell the underlying RDBMS type the current statement is running on and run a raiserror dependant on it (as the method signature is heterogenous). Intra-procedure to support portable code. However, @@servername is the closest I’ve got so far, which is crap, and the syntax check fails on both anyway cos of the method signatures. Nuts and bolts. I think I’m going to have to construct the SQL in calling process which knows what type of rdbms it’s using. Ah well.

DECLARE @errorString varchar(50), @errorValue int
SET @errorString = 'processing date hack'
SET @errorValue = @@error
IF LEFT(@@SERVERNAME, 3) = 'SYB'
BEGIN
RAISERROR 17000 'Failed while processing %1! with error no %2!.', @errorString, @errorValue
END
ELSE
RAISERROR ('Failed while processing %s with error no %d.',
16, 1, @errorString, @errorValue)
END

Advertisements
This entry was posted in 1 and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s