How can we help you today? How can we help you today?

'The value assigned here is never used' - but it is

I have a SQL Pattern which SQL Prompt shreds a incorrect - here is an outline of the code. As you can see - the two variables are assigned, used and returned. Any idea why the SQL Prompt thinks the value assigned is not used?
BEGIN
DECLARE -- User Friendly Constants
@Failed BIT = 1,
@Succeeded BIT = 0; -- This will say 'The value assigned here is never used'


DECLARE -- Derived Constants
@ExecutionStatus INT = @Succeeded;-- This will say 'The value assigned here is never used'
BEGIN TRY
...Code
END TRY
BEGIN CATCH
-- Handle the Error
SET @ExecutionStatus = @Failed; -- so if we fail - we are changing the value

EXECUTE dbo.usp_LogErrorInfo;
END CATCH
RETURN @ExecutionStatus; -- so we are either using the initially assigned value or the value assigned in the try/catch block
END
Ozzie
0

Comments

3 comments

  • Aaron L
    Hi Doug,

    Thanks for your post, I can recreate the issue here and I'll look into a fix now. I think Prompt is (wrongly) assuming that the catch statement is going to be hit every time.

    Thanks,
    Aaron.
    Aaron L
    0
  • Aaron L
    I think I've got a fix for the issue in the latest 6.5 beta build which you can download from here.

    Hopefully that fixes it for you, but if not just let me know!

    Thanks,
    Aaron.
    Aaron L
    0
  • Ozzie
    It is fixed in version 6.5.0.271 - fantastic job guys!

    Ozzie
    Ozzie
    0

Add comment

Please sign in to leave a comment.