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 > type conversion

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-25-07, 11:40
ahmedwaseem2000 ahmedwaseem2000 is offline
Registered User
 
Join Date: Jan 2005
Posts: 75
type conversion

Hi ,

Can any one tell me how to convert varchar to integer in the sub query.

i have tried the below code and it's not working.

Code:
select * from Table1 where COL1 NOT IN (SELECT COL2 AS INTEGER FROM Table2 WHERE CODE_CATG_N='XXXX')
Quote:
col1 is smallint and col2 is varchar
the error it is giving is

Quote:
SQL0401N The data types of the operands for the operation "IN" are not
Reply With Quote
  #2 (permalink)  
Old 05-25-07, 12:14
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
That would be CAST() or INTEGER(), not "COL2 AS INTEGER".
Reply With Quote
  #3 (permalink)  
Old 05-25-07, 13:33
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
The current syntax doesn't trigger a syntax error because "COL2 AS INTEGER" is allowed - it just renames the column from COL2 to the name INTEGER.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

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