Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2011
    Posts
    4

    Red face Unanswered: 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

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,737
    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.
    Last edited by Marcus_A; 03-26-11 at 20:33.
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •