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 2000 Forums
 SQL Server Development (2000)
 IS THIS PROCEDURE CORRECT ?

Author  Topic 

paradise_wolf
Starting Member

32 Posts

Posted - 2006-11-02 : 20:19:33

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CREATE PROCEDURE RegisterDownload
(@UserName, @Title)
AS
UPDATE CustomerDownlList
SET NumDownloads = NumDownloads + 1
WHERE UserName = @UserName AND Title = @Title

SET Downloaded = 1 WHEN NumDownloads = Quantity
WHERE UserName = @UserName AND Title = @Title

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In ( SET Downloaded = 1 WHEN NumDownloads = Quantity ) sentence I wanted to do what in C# language would be equivalent to:

If(UserName == @UserName && Title == @Title )
{
if (NumDownloads == Quantity) Downloaded = 1;
}

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-11-02 : 20:26:56
[code]
CREATE PROCEDURE RegisterDownload
(@UserName varchar(50), @Title varchar(50))
AS
UPDATE CustomerDownlList
SET NumDownloads = NumDownloads + 1
WHERE UserName = @UserName AND Title = @Title

UPDATE CustomerDownlList
SET Downloaded = 1 WHEN WHERE NumDownloads = Quantity
WHEREAND UserName = @UserName AND Title = @Title
[/code]


KH

Go to Top of Page

paradise_wolf
Starting Member

32 Posts

Posted - 2006-11-02 : 20:41:21
Thank you, khtan
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-11-02 : 21:47:32
You need to specify datatypes for the procedure parameters.

Something like:
CREATE PROCEDURE RegisterDownload
(@UserName varchar(40), @Title varchar(40))
AS
...rest of code...


CODO ERGO SUM
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-11-02 : 22:26:27
missed that


KH

Go to Top of Page
   

- Advertisement -