May 3, 2004 at 12:39 am
Hi,
I'm having some trouble with a small piece of code
I'm sure it's a no brainer but, my brain is not working it out
I use a varible called @OpenMode in my procedure to determine which piece(s) to run.
Here's an example
--====================================
IF @OpenMode = 'updprf'
--====================================
BEGIN
[need help on this line] see below
UPDATE tblProfile
SET
FName = @FName,
LName = @LName
WHERE uID = @uID
END
--====================================
IF @OpenMode = 'getprf'
--====================================
BEGIN
SELECT *
FROM tblProfile
WHERE uID = @uID
END
---------------------------------------------------------------
How would I get an IF statement to work in there?
I'd like to do something like this
DECLARE @status varchar (10)
SELECT @status = Status FROM tblProfile WHERE uID = @uID
IF @status = 'live' THEN
INSERT INTO tblResult
(uID, Location, Status)
Values
(@uID, @Location, @status)
END IF
I'm just looking to determine a value and create a record in another table if the statement is true, otherwise just skip past and on to the next.
Any help would be greatly appreciated
Rick
May 3, 2004 at 9:12 am
Yeah it should work , however BEGIN and END optional tags may be useful if you want to add anything in addition to just this code block
DECLARE @status varchar (10)
SELECT @status = Status FROM tblProfile WHERE uID = @uID
IF @status = 'live'
BEGIN
INSERT INTO tblResult
(uID, Location, Status)
Values
(@uID, @Location, @status)
END
Thanks
Prasad Bhogadi
www.inforaise.com
May 4, 2004 at 7:11 am
Thank you Prasad!
It worked perfectly!
Rick
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply