Issue With Raiseerror

Apr 11, 2008

I have an issue with the error message that is being raised in a stored procedure:

RAISERROR('Error inserting Value %d into Order_Header_Reference_Code_XREF for Order_Header_ID %d and Reference_Code_ID %d', 10, 1, @Value, @OrderHeaderID, @ReferenceCodeID)

Here is the result after executing my procedure with "@Value = 'test'"

Error inserting Value 114994016 into Order_Header_Reference_Code_XREF for Order_Header_ID 10801 and Reference_Code_ID 1

 

114994016 should say 'test' right?

Does anyone see an issue with my raiseerror statement?

View 3 Replies


ADVERTISEMENT

RAISEERROR Not Throwing Exception In .NET

Jul 9, 2007

I am calling a stored procedure that looks like this.


Code:


ALTER PROCEDURE [dbo].[VerifyLogin]
-- Add the parameters for the stored procedure here
@Email nvarchar (100),
@Password nvarchar (200)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

DECLARE @Count int
DECLARE @Accounts int

SET @Accounts = (Select Count(*) from Users Where UPPER(Email) = UPPER(@Email))

IF @Accounts = 0
BEGIN
RAISERROR('E-mail address not found.', 10, 1)
END
ELSE
BEGIN
SET @Count = (Select Count(*) from Users Where UPPER(Email) = UPPER(@Email) and Password = @Password)

IF @Count > 0
select 1 as Verification
ELSE
select 0 as Verification
END
END



When I enter a login that does not exist, the error is not thrown in .net. Tracing the code shows normal execution. What am I doing wrong?

View 1 Replies View Related

Raiseerror Does Not Raise Exception

Aug 16, 2006

Hi friends



i've a stored proc (sql 2005) that'll raiseerror statement when something violated.



but my C# application that calls this stored proc does not any throw exception when this happens !!



i remember visual basic used to through an exception for this type of things.



is it different in C# and how do we handle this scenario ?



Thanks for ur ideas.

View 10 Replies View Related

Check Constraint To RAISEERROR On 547 16 1

Mar 15, 2008



Hi, I need the T-SQL statement on how to raise a custom error message for a check contraint @au_id '[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9]' when ever a client enters the wrong SSN format such as 575-444865. I used the t-sql statement below but does not work when running an insert on the authors table ; au_id column.

CREATE TRIGGER trg_datavalidate
ON authors
FOR INSERT
AS
DECLARE @au_id varchar(11)
DECLARE @err INT

SELECT @err = @@ERROR
from inserted
IF @err = 547
BEGIN
PRINT 'Au_id needs to be in the SSN format xxx-xx-xxxx!. Error Number:'
+ CAST(@err AS VARCHAR)
RAISERROR ('au_id must be in the format of xxx-xxxxxx where x is a number.', -- Message text.
16, -- Severity.
1 -- State.
);
ROLLBACK TRANSACTION
END

View 4 Replies View Related

RAISEERROR From CLR Stored Procedures

May 14, 2005

I'm writing:

View 7 Replies View Related

RaiseError Inside Stored Procedure

Aug 5, 2006

I want to execute some insert statements within a stored procedure and commit those changes regardless of any raiseerror that occurs later in the stored procedure. My difficulty is that I am forced to use raiseerror with severity 16 in order to send a message through the powerbuilder application interface (compiled vendor code). I have tried save points but can't get that to save my insert and still present an error to the user about something else that happens later.



here is an example

BEGIN procedure

Insert something and save it even if error is raised below

RaiseError('you made a mistake and need to do this.',16,-1)

END procedure



View 5 Replies View Related

Is It Possible To Put The Raiseerror In A Text File Or Show It To The User After Its Been Inserted.

Oct 29, 2007

I am in process of building a website where the user can upload files and then those files are loaded in to a sql server database. I am using some sprocs to scrub the data and then insert them into the production database.. And in my sprpc before and after updating or inserting a record or scrubing... i am returning the count by raising an error. or returning the rownumber where the error occured.. is there any way  i can get the raise error part or whatever error i get while scrubing the data and relay it back to the user in a user freindly way or in a text file... or the best thing is can i open smalll window where i can show them what processing is goin on and alert them if there are any errors...
 Any help will be appreciated.
Regards
Karen 
  

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved