If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > how to perfom check between different data types in db2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-26-11, 07:09
sanjay bharkatiya sanjay bharkatiya is offline
Registered User
 
Join Date: Mar 2011
Posts: 4
Red face how to perfom check between different data types in db2

i need to check if the two colums has the same value or not , say for eg :

in table road , i have two colums frc(int) and frc_m (varchar[1]),

frc has values like 0,1,2,3,4,5
frc_m has values like 3,4,5,blank, it can have a blank value so it is varchar[1] , if i make it a int then blank will replaced with 0 , that i dont want .

now i want the equality check between frc and frc_m in my stored proc
like if(frc=frc_m)
then
insert into ......
end if;

please provide me the solution for that .

sanjay
Reply With Quote
  #2 (permalink)  
Old 03-26-11, 13:20
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,198
Use the CAST statement to convert the int to varchar, and use the CASE statement to change the 0 to a blank.

Edit: I corrected my typo, Yes I meant CAST.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390

Last edited by Marcus_A; 03-26-11 at 19:33.
Reply With Quote
  #3 (permalink)  
Old 03-26-11, 17:18
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Quote:
Originally Posted by Marcus_A View Post
Use the CADT statement to convert the int to varchar, and use the CASE statement to change the 0 to a blank.
I guess Marcus meant CAST
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
Reply

Tags
data type, db2

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On