Hi all,
I would like know if I can use @.@.ERROR to error in mult thread environment?
For sample:
If this SP is executed by 2 threads in same time, I wiil have correct value
in @.@.ERROR
Thanks
IF EXISTS (SELECT name
FROM sysobjects
WHERE name = N'terminal_ativo_sp'
AND type = 'P')
DROP PROCEDURE terminal_ativo_sp
GO
CREATE PROCEDURE terminal_ativo_sp
@.tid uterminalid,
@.ret INT OUTPUT
WITH ENCRYPTION
AS
BEGIN
-- declare vars
-- ----
--
DECLARE @.ativo BIT
-- init vars (assume SYS ERROR)
-- ----
--
SET @.ret = 101
SET @.ativo = 0
-- do work
-- ----
--
SELECT @.ativo = ativo FROM estabelecimentos_terminais WHERE terminal_id =
@.tid
-- check error
-- ----
--
IF (@.@.ERROR <> 0)
BEGIN
SET @.ret = 1
RETURN
END
-- check @.ativo
-- ----
--
IF (@.ativo = 1)
BEGIN
SET @.ret = 0
RETURN
END
ENDIts specific to the database connection and is not affected by any other
connection.
So, yes your code is fine.
Tony.
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials
"ReTF" <re.tf@.newsgroup.nospam> wrote in message
news:uAcEXet5FHA.1276@.TK2MSFTNGP09.phx.gbl...
> Hi all,
> I would like know if I can use @.@.ERROR to error in mult thread
> environment?
> For sample:
> If this SP is executed by 2 threads in same time, I wiil have correct
> value in @.@.ERROR
> Thanks
>
> IF EXISTS (SELECT name
> FROM sysobjects
> WHERE name = N'terminal_ativo_sp'
> AND type = 'P')
> DROP PROCEDURE terminal_ativo_sp
> GO
> CREATE PROCEDURE terminal_ativo_sp
> @.tid uterminalid,
> @.ret INT OUTPUT
> WITH ENCRYPTION
> AS
> BEGIN
> -- declare vars
> -- ----
--
> DECLARE @.ativo BIT
> -- init vars (assume SYS ERROR)
> -- ----
--
> SET @.ret = 101
> SET @.ativo = 0
> -- do work
> -- ----
--
> SELECT @.ativo = ativo FROM estabelecimentos_terminais WHERE terminal_id =
> @.tid
> -- check error
> -- ----
--
> IF (@.@.ERROR <> 0)
> BEGIN
> SET @.ret = 1
> RETURN
> END
> -- check @.ativo
> -- ----
--
> IF (@.ativo = 1)
> BEGIN
> SET @.ret = 0
> RETURN
> END
> END
>
No comments:
Post a Comment