If condition is not working properly

  • Hi I have this if condition that invokes one stored procedure else invoke another.  However only the first condition is being executed and nothing is happening to the second stored procedure.  Am I missing something is it a syntax issue.  Here's the sproc:  Thanks in advanced

     

    PROCEDURE dbo.Supplyrequest_Updateassignbuyers

    (

    @Proposalno VARCHAR(50),

    @Requestid INT,

    @Si VARCHAR(8000),

    @Assignbuyer BIT

    )

    AS

    DECLARE @Error INT

    SET NOCOUNT ON

     UPDATE Request_for_quote

     SET Assignbuyer = @Assignbuyer,specialInstructions = @Si

     WHERE requestNumber = @Requestid AND proposalnumber = @Proposalno

     -- Assign flags

     IF @Assignbuyer = 1

      BEGIN

      -- If flag is set to value 1 then this will go to the buyer coordinator need to assign cost1 associated value as TBD    

       EXEC Supplyrequest_Updateassigntocoordinator @Proposalno = @Proposalno,@Requestid = @Requestid,@Assignbuyer = @Assignbuyer

      END

     ELSE --- NEVER REACHES THIS POINT

      BEGIN

      -- If flag is not assign send this record to load proposal and assign value 9999999 to cost1 and leadtime  

       EXEC Supplyrequest_Updateoktoprocessexceptions @Proposalno = @Proposalno,@Requestid = @Requestid

      END

                              

    RETURN

    SET @Error = @@ERROR

    IF @Error <> 0

     BEGIN

             RETURN @Error

     END

    RETURN @Error

     

  • The problem could lie in Supplyrequest_Updateoktoprocessexceptions  and not here. Nothing is jumping out to me here.

    I would suggest usign Profiler to watch the sql statements ran and the stroed procedures called. Make sure the pieces are working and that no triggers exist on the destination table(s) which might rollback the input.

  • Thanks for the quick response;  Here is the stored procedure script for the second sproc.  Nothing special:

    ALTER     PROCEDURE dbo.Supplyrequest_Updateoktoprocessexceptions

    (

    @Proposalno INT,

    @Requestid INT

    )

    AS

    DECLARE @Error INT

    SET NOCOUNT ON

    UPDATE Request_for_quote

     SET OKToprocessexp = 1, qtyException = 0, Assignbuyer = 0,Cost1 = 9999999,Leadtime = 9999999

     WHERE requestNumber = @Requestid AND proposalnumber = @Proposalno

                              

     

    RETURN

    SET @Error = @@ERROR

    IF @Error <> 0

     BEGIN

             RETURN @Error

     END

    RETURN @Error

  • Sorry to ask this but..

    if you print your @Assignbuyer you do see a value other than 1 ?!?!

    also...your assignment to @Si should be corrected to:

    SET ......, @SI = specialInstructions 
     WHERE requestNumber = @Requestid AND proposalnumber = @Proposalno..
    

    Your proposalnumber is actually varchar(50) and not an int ?!?! Maybe the value needs to be trimmed or something ?!







    **ASCII stupid question, get a stupid ANSI !!!**

  • Er, sushila, I think you're wrong there. I think you read the original too quickly. The SET statement you're quoting there is part of an UPDATE query. He's setting values in the table to be equal to the inputted variables, not the other way around.

    I'm with Antares686 here, though. Nothing about that IF statement looks funky. Have you checked the updated Request_for_quote values, to see what value of @Assignbuyer is being stored?

  • Too quick indeed - I could swear that when I read it I didn't see any updates, and the set statement was assigning values to the variables...apologies Joe...

    ps:Joe - you didn't edit the first post later did you ?!?!







    **ASCII stupid question, get a stupid ANSI !!!**

  • Thanks everyone for your help.  My issue is not with the sproc, but rather with the .NET grid that I purchased.  Apparently it evaluates only checked off items, therefore the evaluation in the sproc will always be true (1).  Brain fart on my part for not evaluating the grid earlier.  My workaround is adding another checkbox column in the grid in order for this to get evaluated as well.

    Apology accept Sushila.  Anytime I can get objective views as always a great help.

    Thanks,

    Joe

  • Objective view you say?...

    create view objective as select 'poor joke' as 'objective view'

    Ryan Randall

    Solutions are easy. Understanding the problem, now, that's the hard part.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply