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.
| Author |
Topic |
|
ankur_gurha
Starting Member
20 Posts |
Posted - 2007-08-28 : 06:50:57
|
| Hi guys,This is my simple stored procedure ALTER PROCEDURE [dbo].[spPA_IsApplicationBlocked]( @ApplicationName varchar(255), @IsBlocked bit OUTPUT)AS SELECT @IsBlocked = IsBlocked FROM dbo.Application WHERE ApplicationName = @ApplicationNameMy problem is the sp returns me a null value is the Application name doesnt matches when it executes. Please help as what am i doing wrong.Thanks in advance. |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-28 : 07:00:49
|
| add this to the endSELECT @IsBlocked = IsNull(@IsBlocked, 0)_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-28 : 07:27:33
|
Well... There is a problem with that, Spirit.If the SELECT statement do not return any records at all (ie ApplicationName doed not exists), @IsBlocked is still NULL.ALTER PROCEDURE [dbo].[spPA_IsApplicationBlocked](@ApplicationName varchar(255),@IsBlocked bit OUTPUT)ASSELECT @IsBlocked = IsBlockedFROM dbo.ApplicationWHERE ApplicationName = @ApplicationNameSET @IsBlocked = ISNULL(@IsBlocked, 0)orALTER PROCEDURE [dbo].[spPA_IsApplicationBlocked](@ApplicationName varchar(255),@IsBlocked bit OUTPUT)ASSET @IsBlocked = 0SELECT @IsBlocked = IsBlockedFROM dbo.ApplicationWHERE ApplicationName = @ApplicationName E 12°55'05.25"N 56°04'39.16" |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-08-28 : 07:33:07
|
there is no problem with that.it's a new statement that does exactly that. first it's his select where if it returns nothing @IsBlocked remains nullthe second (mine) select takes care of that.No?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenp |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-08-28 : 07:38:41
|
Ahhh! Now I see! I thought you replace the SELECT statement from the table itself.Sorry! E 12°55'05.25"N 56°04'39.16" |
 |
|
|
ankur_gurha
Starting Member
20 Posts |
Posted - 2007-08-28 : 07:49:11
|
| Thanks guys, help is much appreciated. |
 |
|
|
|
|
|