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 2008 Forums
 Transact-SQL (2008)
 Print statement want to see output values via sp

Author  Topic 

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2012-07-12 : 14:47:38
Using teh following on sql server query analyzer window: want to see teh output @Result value, using print statement at the bottom, but i don't see anything.

exec USP_IsThisStepOKToAdd 592,'SU',1,'07/12/2012',0,0





-------------
ALTER PROCEDURE [dbo].[USP_IsThisStepOKToAdd]
@ModId int,
@ModuleName varchar(50),
@Step int,
@DueDate DateTime,
@Result bit output,
@Message Int OUTPUT
AS
BEGIN
SET @Message = ''

DECLARE @MaxStepClosed Int, @MinStepOpen Int, @MinDueDateForMinStep DateTime, @MinDateForNextStep DateTime

SET @MaxStepClosed = 0
SET @MinStepOpen = 0
SET @MinDueDateForMinStep = GetDate()

IF EXISTS(SELECT 1 FROM dbo.Tab_WorkflowActivity WHERE ModuleRecordID = @ModId AND ModuleName = @ModuleName)
BEGIN
IF NOT EXISTS(SELECT 1 FROM dbo.Tab_WorkflowActivity WHERE ModuleRecordID = @ModId AND ModuleName = @ModuleName AND (Step = (@Step - 1) OR @Step = 1))
BEGIN
SET @Message = 4 --'No record was found for a Step prior to the one that you are trying to add. Please add an activity for a previous step first and then try this again.'
SET @Result = 0
RETURN
END

SELECT @MaxStepClosed = MAX(Step) FROM Tab_WorkflowActivity WHERE ModuleRecordID = @ModId AND ModuleName = @ModuleName AND DoneDate IS NOT NULL;
SELECT @MinStepOpen = MIN(Step), @MinDueDateForMinStep = MIN(DueDate) FROM Tab_WorkflowActivity WHERE ModuleRecordID = @ModId AND ModuleName = @ModuleName AND DoneDate IS NULL;
SELECT @MinDateForNextStep = MIN(DueDate) FROM Tab_WorkflowActivity WHERE ModuleRecordID = @ModId AND ModuleName = @ModuleName AND Step > @Step;

IF @Step < @MaxStepClosed
BEGIN
SET @Message = 1 --'An activity in the Step greater then this Step chosen by you has been completed. So you will not be able to add a new activity in this step.'
SET @Result = 0
RETURN
END
IF @Step > @MinStepOpen AND @DueDate < @MinDueDateForMinStep
BEGIN
SET @Message = 2 --'An activity in the Step prior then this Step chosen by you has a Due Date ahead of the Due Date chosen by you for this step. So you will not be able to add a new activity in this step.'
SET @Result = 0
RETURN
END
IF @DueDate > @MinDateForNextStep
BEGIN
SET @Message = 3 --'An activity in a step higher then the one you were trying to save, has a due date prior to this date. You can't this activity.'
SET @Result = 0
RETURN
END
END
ELSE IF @Step <> 1
BEGIN
SET @Message = 5 --'Workflow doesn't have activity defined yet. Please start with Step 1 first and then go on to higher steps.'
SET @Result = 0
RETURN
END

SET @Result = 1


END
print @Result





thanks a lot for the helpful info.

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-07-12 : 14:51:38
the other tab in the result pane?


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2012-07-12 : 14:53:10
I am not getting the other tab in teh results pane, all i see is message tab.

I am using sql server 2008 R2.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-07-12 : 15:08:01
Ah - now I see.
You have to declare a variable with the same data type as the output parameter of the called stored procedure to take the value.
Like this:

declare @getOutputResult bit
declare @getOutputMessage int
exec USP_IsThisStepOKToAdd 592,'SU',1,'07/12/2012',@Result=@getOutputResult output, @Message=@getOutputMessage output

print @getOutputResult
print @getOutputMessage



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

cplusplus
Aged Yak Warrior

567 Posts

Posted - 2012-07-12 : 15:12:25
Thanks a lot webfred.....
Go to Top of Page
   

- Advertisement -