473,808 Members | 2,838 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DECODE in DB2 8.1?

I come from the oracle world and would use the Oracle 'DECODE'
function
extensively. Is there any equivalent in db2???

using db2 version 8.1 on win

SELECT COUNT(*) INTO VAR_COUNT_STREE T
FROM TB_TOWN_STREET
WHERE upper(trim(STRE ETNAME)) = upper(trim(STRE ET))
AND upper(trim(TOWN _NAME)) = upper(trim(TOWN ))
AND DECODE (trim(IN_STREET _TYPE),'','1',t rim(IN_STREET_T YPE)) = DECODE
(trim(IN_STREET _TYPE),'','1', trim(STREETTYPE ));

Please, write this oracle script in Db2 language

Thanks.

Apr 17 '07 #1
2 10366
Hi,
coming from oracle too.
That's my try:
SELECT COUNT(*) INTO VAR_COUNT_STREE T
FROM TB_TOWN_STREET
WHERE upper(trim(STRE ETNAME)) = upper(trim(STRE ET))
AND upper(trim(TOWN _NAME)) = upper(trim(TOWN ))
AND ( CASE ( when trim(IN_STREET_ TYPE) = '' then '1'
else trim(IN_STREET_ TYPE)) ) -- <<< IN_ ??
= ( CASE when trim(IN_STREET_ TYPE) = '' then '1'
else trim(STREETTYPE )));
hth
Kay

Apr 17 '07 #2
Kay Kanekowski wrote:
Hi,
coming from oracle too.
That's my try:
SELECT COUNT(*) INTO VAR_COUNT_STREE T
FROM TB_TOWN_STREET
WHERE upper(trim(STRE ETNAME)) = upper(trim(STRE ET))
AND upper(trim(TOWN _NAME)) = upper(trim(TOWN ))
AND ( CASE ( when trim(IN_STREET_ TYPE) = '' then '1'
else trim(IN_STREET_ TYPE)) ) -- <<< IN_ ??
= ( CASE when trim(IN_STREET_ TYPE) = '' then '1'
else trim(STREETTYPE )));
In DECODE NULL = NULL. Since in Oracle '' IS NULL as well, I think you
may need:
COALECSE(trim(I N_STREET_TYPE), '') = ''
... if IN_STREET_TYPE can be NULL (or '' in Oracle).

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Apr 17 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2398
by: Matt Oefinger | last post by:
Hello gurus, I'm trying to do a search through an encrypted database (to which I have the key). I want to use the LIKE operator in MySQL rather than dumping out all entries and sorting in Perl, since MySQL will be much faster at digging up the right information. I'm not having any luck with the following (I'm using DBI in Perl, so $ is Perl variable stuff):
10
111284
by: N | last post by:
What is the function in SQL that works like DECODE in Oracle?" Thanks, N
4
4928
by: Newbie | last post by:
How would I modify this form to encode *all* the characters in the 'source' textarea to the '%xx' format & place result code into the 'output' textarea? (cross browser compatable) Any help is appreciated. Regards.
1
3732
by: richasaraf | last post by:
Hello everyone, I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then basic problem is the CASE has NOT condition i.e. <> ...... and this particularly i'm not able to convert in DECODE. Please send me the solution as early as possible.. I'm stuck up !!! I'm giving below the CASE statements and the DECODE statements which i have...
0
3502
by: richasaraf | last post by:
Hello everyone, Please HELP !!!!! I'm facing problem in converting CASE statements into DECODE. As i have PL/SQL 8i, so it does not handle CASE statements. Please send me the solutions . Then basic problem is the CASE has NOT condition i.e. <> ...... and this particularly i'm not able to convert in DECODE. Please send me the solution as early as possible.. I'm stuck up !!! I'm giving below the CASE statements and the DECODE...
0
1522
by: Simon | last post by:
Newbie alert! I have a webform listbox with what I am sure is a common requirement. I wish to store a list of values but display a "translation" or decode. An example would be 1, 2, 3, 4 and One, Two, Three, Four I created class ListBoxSpecial { public string Code;
2
10324
by: aurora | last post by:
I have some unicode string with some characters encode using python notation like '\n' for LF. I need to convert that to the actual LF character. There is a 'unicode_escape' codec that seems to suit my purpose. >>> encoded = u'A\\nA' >>> decoded = encoded.decode('unicode_escape') >>> print len(decoded) 3 Note that both encoded and decoded are unicode string. I'm trying to use
2
3429
by: rsd | last post by:
Hi, I'm trying get Samsung YH-920 mp3 player to work with Debian GNU/Linux. To do that I need to run http://www.paul.sladen.org/toys/samsung-yh-925/yh-925-db-0.1.py script, the idea behind the script is described at http://www.paul.sladen.org/toys/samsung-yh-925/ I'm getting errors and hoping someone could give me some hints, for I have no python background.
1
2776
by: dande | last post by:
my problem is I have used invoice table, patient table.In Invoice table date,cash,credit, cheque,advance,total is coming.but in patient table having registration type code having gen registraion means gen, external reg means ext,acccident & emergency reg means AE.hear patient,invoice table have date column.but I have to display invoice date. that date no of gen reg, ext reg,ae reg not coming when joining two tables.gen reg, ext reg, AE reg i...
1
5782
by: anonymous | last post by:
1 Objective to write little programs to help me learn German. See code after numbered comments. //Thanks in advance for any direction or suggestions. tk 2 Want keyboard answer input, for example: answer_str = raw_input(' Enter answer ') Herr Üü
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10628
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
7651
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6880
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5547
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3859
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.