Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

sp_getmessage equivalent

5 posts in General Discussion Last posting was on 2012-04-20 16:48:18.0Z
Mark Posted on 2012-04-19 15:18:23.0Z
From: Mark <mlibner@yahoo.com>
Reply-To: mlibner@yahoo.com
Organization: Security Finance
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: sp_getmessage equivalent
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4f902cbf@forums-1-dub>
Date: 19 Apr 2012 08:18:23 -0700
X-Trace: forums-1-dub 1334848703 10.22.241.152 (19 Apr 2012 08:18:23 -0700)
X-Original-Trace: 19 Apr 2012 08:18:23 -0700, vip152.sybase.com
Lines: 8
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31047
Article PK: 73937

I'm looking for a mechanism that will give me the description column of
the error in sysmessages. It appears sp_getmessage only works for error
codes above 17000.

Thanks,
Mark

ASE 15.5


Bret Halford Posted on 2012-04-19 19:09:11.0Z
From: Bret Halford <bret@sybase.com>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: sp_getmessage equivalent
References: <4f902cbf@forums-1-dub>
In-Reply-To: <4f902cbf@forums-1-dub>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4f9062d7$1@forums-1-dub>
Date: 19 Apr 2012 12:09:11 -0700
X-Trace: forums-1-dub 1334862551 10.22.241.152 (19 Apr 2012 12:09:11 -0700)
X-Original-Trace: 19 Apr 2012 12:09:11 -0700, vip152.sybase.com
Lines: 46
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31048
Article PK: 73938


On 4/19/2012 9:18 AM, Mark wrote:
> I'm looking for a mechanism that will give me the description column of
> the error in sysmessages. It appears sp_getmessage only works for error
> codes above 17000.
>
> Thanks,
> Mark
>
> ASE 15.5

You can create your own procedures in master or sybsytemprocs.
Start the procedure name with "sp_" to allow it to be called
from any database (ASE first looks for "sp_" procs in the local
database, then sybsystemprocs, then master). For a more robust
procedure make a copy of the sp_getmessage ddl and then modify
it, but as a simple example:

1> use master
2> go
1> create procedure sp_geterror @errorid int as
2> select * from master..sysmessages where error = @errorid
3> go
1> use tempdb
2> go
1> sp_geterror 205
2> go
error severity dlevel
description
langid sqlstate
----------- -------- ------

------------------------------------------------------------------------------
------ --------
205 16 2
All queries in a SQL statement containing set operators must
have an eq
ual number of expressions in their target lists.
NULL NULL
205 16 2
Todas las consultas de una instrucci≤n SQL que contengan SET
deben tene
r un n·mero igual de expresiones en sus listas de destino.
1 NULL

(2 rows affected)
(return status = 0)


Mark Posted on 2012-04-20 14:17:35.0Z
From: Mark <mlibner@yahoo.com>
Reply-To: mlibner@yahoo.com
Organization: Security Finance
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: sp_getmessage equivalent
References: <4f902cbf@forums-1-dub> <4f9062d7$1@forums-1-dub>
In-Reply-To: <4f9062d7$1@forums-1-dub>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4f916fff@forums-1-dub>
Date: 20 Apr 2012 07:17:35 -0700
X-Trace: forums-1-dub 1334931455 10.22.241.152 (20 Apr 2012 07:17:35 -0700)
X-Original-Trace: 20 Apr 2012 07:17:35 -0700, vip152.sybase.com
Lines: 60
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31050
Article PK: 73940

Hi Bret,

Thanks for your reply. I've created a mirror image of sp_gemessage and
it works fine with one problem. Some of the messages contain
placeholders that get populated by something internally I'm guessing.
For example error code 532. How do these placeholders get populated?

select * from master..sysmessages where error = 532

Thanks again,
Mark

On 4/19/2012 3:09 PM, Bret Halford wrote:
> On 4/19/2012 9:18 AM, Mark wrote:
>> I'm looking for a mechanism that will give me the description column of
>> the error in sysmessages. It appears sp_getmessage only works for error
>> codes above 17000.
>>
>> Thanks,
>> Mark
>>
>> ASE 15.5
>
> You can create your own procedures in master or sybsytemprocs.
> Start the procedure name with "sp_" to allow it to be called
> from any database (ASE first looks for "sp_" procs in the local
> database, then sybsystemprocs, then master). For a more robust
> procedure make a copy of the sp_getmessage ddl and then modify
> it, but as a simple example:
>
> 1> use master
> 2> go
> 1> create procedure sp_geterror @errorid int as
> 2> select * from master..sysmessages where error = @errorid
> 3> go
> 1> use tempdb
> 2> go
> 1> sp_geterror 205
> 2> go
> error severity dlevel
> description
> langid sqlstate
> ----------- -------- ------
>
> ------------------------------------------------------------------------------
>
> ------ --------
> 205 16 2
> All queries in a SQL statement containing set operators must
> have an eq
> ual number of expressions in their target lists.
> NULL NULL
> 205 16 2
> Todas las consultas de una instrucci≤n SQL que contengan SET
> deben tene
> r un n·mero igual de expresiones en sus listas de destino.
> 1 NULL
>
> (2 rows affected)
> (return status = 0)


Bret Halford Posted on 2012-04-20 16:48:18.0Z
From: Bret Halford <bret@sybase.com>
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: sp_getmessage equivalent
References: <4f902cbf@forums-1-dub> <4f9062d7$1@forums-1-dub> <4f916fff@forums-1-dub>
In-Reply-To: <4f916fff@forums-1-dub>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4f919352$1@forums-1-dub>
Date: 20 Apr 2012 09:48:18 -0700
X-Trace: forums-1-dub 1334940498 10.22.241.152 (20 Apr 2012 09:48:18 -0700)
X-Original-Trace: 20 Apr 2012 09:48:18 -0700, vip152.sybase.com
Lines: 34
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31052
Article PK: 73943


On 4/20/2012 8:17 AM, Mark wrote:
> Hi Bret,
>
> Thanks for your reply. I've created a mirror image of sp_gemessage and
> it works fine with one problem. Some of the messages contain
> placeholders that get populated by something internally I'm guessing.
> For example error code 532. How do these placeholders get populated?
>
> select * from master..sysmessages where error = 532
>
> Thanks again,
> Mark
>

The placeholders are populated by ASE as the error is being raised
based on the actual context at that time
(current timestamp value, table name, user name, database name,
column name, datatype, etc.).

There isn't currently any way to access a copy of the most
recent message with placeholders filled in using a sql query
unless the client application does something fancy like
capture the error messages it receives and stores them
back into a table in ASE.

There is an open feature request to have the full text
of the most recently raised message(s) available as a global
variable.

-bret


Mark Posted on 2012-04-20 15:23:19.0Z
From: Mark <mlibner@yahoo.com>
Reply-To: mlibner@yahoo.com
Organization: Security Finance
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: sp_getmessage equivalent
References: <4f902cbf@forums-1-dub> <4f9062d7$1@forums-1-dub>
In-Reply-To: <4f9062d7$1@forums-1-dub>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4f917f67$1@forums-1-dub>
Date: 20 Apr 2012 08:23:19 -0700
X-Trace: forums-1-dub 1334935399 10.22.241.152 (20 Apr 2012 08:23:19 -0700)
X-Original-Trace: 20 Apr 2012 08:23:19 -0700, vip152.sybase.com
Lines: 53
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:31051
Article PK: 73941

It looks like the problem has been addressed for ASE 16.0.
http://search.sybase.com/kbx/solvedcases?id_number=11498773

That's nice but doesn't help me at the moment.

On 4/19/2012 3:09 PM, Bret Halford wrote:
> On 4/19/2012 9:18 AM, Mark wrote:
>> I'm looking for a mechanism that will give me the description column of
>> the error in sysmessages. It appears sp_getmessage only works for error
>> codes above 17000.
>>
>> Thanks,
>> Mark
>>
>> ASE 15.5
>
> You can create your own procedures in master or sybsytemprocs.
> Start the procedure name with "sp_" to allow it to be called
> from any database (ASE first looks for "sp_" procs in the local
> database, then sybsystemprocs, then master). For a more robust
> procedure make a copy of the sp_getmessage ddl and then modify
> it, but as a simple example:
>
> 1> use master
> 2> go
> 1> create procedure sp_geterror @errorid int as
> 2> select * from master..sysmessages where error = @errorid
> 3> go
> 1> use tempdb
> 2> go
> 1> sp_geterror 205
> 2> go
> error severity dlevel
> description
> langid sqlstate
> ----------- -------- ------
>
> ------------------------------------------------------------------------------
>
> ------ --------
> 205 16 2
> All queries in a SQL statement containing set operators must
> have an eq
> ual number of expressions in their target lists.
> NULL NULL
> 205 16 2
> Todas las consultas de una instrucci≤n SQL que contengan SET
> deben tene
> r un n·mero igual de expresiones en sus listas de destino.
> 1 NULL
>
> (2 rows affected)
> (return status = 0)