Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 RAISERROR

Author  Topic 

sasan_vm
Yak Posting Veteran

51 Posts

Posted - 2011-05-31 : 05:07:19
Hello,

I have a procedure , that may be raiserror on many situation but that
error never shown on client application ? client use C++ and OLEDB for
connection to sql server.


CREATE PROC pr_WaitToTemp
@IdNo varchar(50)
AS
BEGIN
DECLARE @InDate datetime
DECLARE @Repeat bit
DECLARE @GID bigint
DECLARE @Title int
DECLARE @Time datetime
DECLARE @Error int

SET @Time = DATEADD(day, DATEDIFF(day, 0, getdate()), 0)
SELECT TOP 1 @GID = GID, @Title = Title, @InDate = InDate, @Repeat = Repeat FROM tbl_wait WHERE IdNo = @IdNo
IF (@InDate IS NULL OR @Repeat IS NULL)
BEGIN
RAISERROR('ID code not exist.', 16, 1)
RETURN -1
END

BEGIN TRANSACTION MOVE_TO_TEMP_1

INSERT INTO tmp4out (IdNo, InDate, OutDateOrd, Repeat) VALUES (@IdNo, @InDate, @Time, @Repeat)
SELECT @Error = @@ERROR
IF @Error <> 0
BEGIN
ROLLBACK TRANSACTION MOVE_TO_TEMP_1
RETURN -2
END

DELETE FROM tbl_wait WHERE IdNo = @IdNo
SELECT @Error = @@ERROR
IF @Error <> 0
BEGIN
ROLLBACK TRANSACTION MOVE_TO_TEMP_1
RETURN -3
END

COMMIT TRANSACTION MOVE_TO_TEMP_1

BEGIN TRANSACTION MOVE_TO_TEMP_2

INSERT INTO tbl_waitarchive (GID, Title, IdNo, InDate, OutDateOrd, Stay) VALUES (@GID, @Title, @IdNo, @InDate, @Time, DATEDIFF(day, @InDate, @Time))
SELECT @Error = @@ERROR
IF @Error <> 0
BEGIN
RAISERROR('Can not insert in archive.', 16, 1)
ROLLBACK TRANSACTION MOVE_TO_TEMP_2
RETURN -4
END

COMMIT TRANSACTION MOVE_TO_TEMP_2
RETURN @Error
END


Kind Regards,
sasan.

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-05-31 : 07:12:58
You must change the c++ application to take in to account the raiserror messages

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/
Go to Top of Page

sasan_vm
Yak Posting Veteran

51 Posts

Posted - 2011-05-31 : 07:15:08
Hello all,
That is not related to sql server, that is related to VCL library structure that I used on client.

Kind Regards,
sasan.
Go to Top of Page
   

- Advertisement -