IS THIS PROCEDURE CORRECT ?

  •  

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

    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 set the Downloaded to 1 IF NumDownloads = Quantity.  I am not sure if WHEN operator works like a conditional IF though.

  • hi

    try this

    UPDATE CustomerDownlList

    set Downloaded =case when numdownloads = quantity  then 1 else Downloaded  end where username = @username and title = @title

    "Keep Trying"

Viewing 2 posts - 1 through 1 (of 1 total)

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