Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / March 2006

Tip: Looking for answers? Try searching our database.

SQL construct conversion...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gaurigirish@yahoo.com - 28 Mar 2006 22:59 GMT
How can I convert the following T-SQL construct to SQL-PL?

if @ParameterType not in ('p1', 'p2', 'p3', 'p4', 'p4', 'p5')
begin
   print 'good parameter'
end
else
begin
   print 'bad parameter'
end

I want to avoid using a nested if...then....elseif...,  if possible. I
am newbie to DB2 UDB.
Brian Tkatch - 28 Mar 2006 23:10 GMT
CASE should work fine.

CASE Parameter_Type
  WHEN NOT IN 'p1', 'p2', 'p3', 'p4', 'p4', 'p5') THEN 'Good
Parameter'
  ELSE 'Bad Parameter'
END

In a sample FUNCTION:

CREATE FUNCTION A (Parameter_Type VARCHAR(2))
RETURNS VARCHAR(15)
RETURN
CASE Parameter_Type
  WHEN NOT IN 'p1', 'p2', 'p3', 'p4', 'p4', 'p5') THEN 'Good
Parameter'
  ELSE 'Bad Parameter'
END

VALUES A('p1')
VALUES A('qq')

B
Serge Rielau - 29 Mar 2006 02:09 GMT
> CASE should work fine.
>
[quoted text clipped - 17 lines]
> VALUES A('p1')
> VALUES A('qq')
.. and DB2 supports:
IF THEN ELSEIF /* <-- no space ! */ END IF

Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.