niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Databases » Sybase
How do I streamline this code?
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
Author Message
sharona
*nix forums beginner


Joined: 24 Jun 2005
Posts: 6

PostPosted: Mon Jun 26, 2006 12:44 pm    Post subject: How do I streamline this code? Reply with quote

Hi,

I have 3 blocks of code that are identical, can you tell me how to
rewrite this in a Sybase stored procedure so that I only have to write
the logic once?

SELECT @SourceRating = CASE
WHEN (@Source = "pr") THEN 3
WHEN (@Source = "qa") THEN 2
ELSE 1
END

SELECT @OwnerRating = CASE
WHEN (@AssetOwner = "pr") THEN 3
WHEN (@AssetOwner = "qa") THEN 2
ELSE 1
END

SELECT @StewardRating = CASE
WHEN (@Steward = "pr") THEN 3
WHEN (@Steward = "qa") THEN 2
ELSE 1
END

Thanks.
Back to top
Carl Kayser
*nix forums beginner


Joined: 25 May 2005
Posts: 42

PostPosted: Mon Jun 26, 2006 1:18 pm    Post subject: Re: How do I streamline this code? Reply with quote

"sharona" <shari.arman@morganstanley.com> wrote in message
news:1151325874.375626.234160@p79g2000cwp.googlegroups.com...
Quote:
Hi,

I have 3 blocks of code that are identical, can you tell me how to
rewrite this in a Sybase stored procedure so that I only have to write
the logic once?

SELECT @SourceRating = CASE
WHEN (@Source = "pr") THEN 3
WHEN (@Source = "qa") THEN 2
ELSE 1
END

SELECT @OwnerRating = CASE
WHEN (@AssetOwner = "pr") THEN 3
WHEN (@AssetOwner = "qa") THEN 2
ELSE 1
END

SELECT @StewardRating = CASE
WHEN (@Steward = "pr") THEN 3
WHEN (@Steward = "qa") THEN 2
ELSE 1
END

Thanks.


Well, they're not identical, but the point seems to be obvious.

SELECT @SourceRating = CASE
WHEN (@Source = "pr") THEN 3
WHEN (@Source = "qa") THEN 2
ELSE 1
END,
@OwnerRating = CASE
WHEN (@AssetOwner = "pr") THEN 3
WHEN (@AssetOwner = "qa") THEN 2
ELSE 1
END,
@StewardRating = CASE
WHEN (@Steward = "pr") THEN 3
WHEN (@Steward = "qa") THEN 2
ELSE 1
END
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [2 Posts] View previous topic :: View next topic
The time now is Tue Dec 02, 2008 1:01 pm | All times are GMT
navigation Forum index » Databases » Sybase
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Where is this code not freeing memory ? jithoosin C++ 2 Fri Jul 21, 2006 9:39 am
No new posts Where is this code not freeing memory ? jithoosin C++ 1 Fri Jul 21, 2006 9:27 am
No new posts Where is this code not freeing memory ? jithoosin C++ 1 Fri Jul 21, 2006 9:12 am
No new posts Where is this code not freeing memory ? jithoosin C++ 0 Fri Jul 21, 2006 9:09 am
No new posts Code problem Sikandar C 1 Fri Jul 21, 2006 4:21 am

Personal Loans | Mobile Phones | Currency Converter | Loans | Mobile Phones
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2161s ][ Queries: 16 (0.1433s) ][ GZIP on - Debug on ]