Unix Technical Forum

T-SQL to DB2 UDB SQL-PL conversion...

This is a discussion on T-SQL to DB2 UDB SQL-PL conversion... within the DB2 forums, part of the Database Server Software category; --> How can I convert the following T-SQL construct to SQL-PL? if @ParameterType not in ('p1', 'p2', 'p3', 'p4', 'p4', ...


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 06:32 AM
gaurigirish@yahoo.com
 
Posts: n/a
Default T-SQL to DB2 UDB SQL-PL conversion...

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 06:32 AM
dotyet
 
Posts: n/a
Default Re: T-SQL to DB2 UDB SQL-PL conversion...

you can't print in DB2 UDB. You will have to insert your debug
statements in some table and then do a select on that or you can do a
select on sysibm.sysdummy1 table and use a out parameter to print it.

DB2 UDB stored procedures do not support printing.

regards,
dotyet
gaurigirish@yahoo.com wrote:
> 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.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 06:35 AM
Knut Stolze
 
Posts: n/a
Default Re: T-SQL to DB2 UDB SQL-PL conversion...

gaurigirish@yahoo.com wrote:

> 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


CASE
WHEN parameterType NOT IN ('p1', 'p2', 'p3', 'p4', 'p4', 'p5')
THEN 'good parameter'
ELSE 'bad parameter'
END

This is an expression that returns a VARCHAR value. Whatever you do with
this value is up to you. You could either insert it into a table, return
it to the application via a SELECT statement, send it to a UDF to be
written to a file (http://tinyurl.com/agvaw) or whatever else you might
come up with.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:04 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com