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 > DB2 Conversion Error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-31-11, 10:26
dmaheshrao dmaheshrao is offline
Registered User
 
Join Date: May 2011
Posts: 3
DB2 Conversion Error

I am getting below error when I am type casting String to Int in where clause.

Invalid Character found in a character string argument of the function "INT"
SQLSTATE = 22018

WHERE INT(R_FR_CD) <= 123456 AND INT(R_TO_CD) >= 12389
Reply With Quote
  #2 (permalink)  
Old 05-31-11, 11:18
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
The error message fully explains the reason.

For example:
Code:
------------------------------ Commands Entered ------------------------------
VALUES INT('');
------------------------------------------------------------------------------

1          
-----------
SQL0420N  Invalid character found in a character string argument of the 
function "INTEGER".  SQLSTATE=22018
What are the values of R_FR_CD and R_TO_CD?
Reply With Quote
  #3 (permalink)  
Old 05-31-11, 11:32
dmaheshrao dmaheshrao is offline
Registered User
 
Join Date: May 2011
Posts: 3
The values are 123456 and 200007.
I didn't get why VALUES is being used before INT(' ')
Reply With Quote
  #4 (permalink)  
Old 05-31-11, 11:42
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
The values are 123456 and 200007.
Really?

This worked without any error.
Code:
------------------------------ Commands Entered ------------------------------
WITH
 test_data(R_FR_CD , R_TO_CD) AS (
SELECT '123456' , '200007' FROM sysibm.sysdummy1
)
SELECT *
 FROM  test_data
 WHERE INT(R_FR_CD) <= 123456 AND INT(R_TO_CD) >= 12389
;
------------------------------------------------------------------------------

R_FR_CD R_TO_CD
------- -------
123456  200007 

  1 record(s) selected.
Quote:
I didn't get why VALUES is being used before INT(' ')
VALUES INT('') is equivalent to SELECT INT('') FROM sysibm.sysdummy1
Reply With Quote
  #5 (permalink)  
Old 05-31-11, 11:49
dmaheshrao dmaheshrao is offline
Registered User
 
Join Date: May 2011
Posts: 3
The query which you posted worked even for me, but same applies to my query which fails

May be some issue will get back to you soon...

Thanks,
Mahesh
Reply With Quote
  #6 (permalink)  
Old 05-31-11, 12:02
tonkuma tonkuma is online now
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
..., but same applies to my query which fails
So, the values of R_FR_CD and R_TO_CD are not '123456' and '200007'.
Reply With Quote
  #7 (permalink)  
Old 05-31-11, 12:46
Stealth_DBA Stealth_DBA is offline
Registered User
 
Join Date: May 2009
Posts: 472
dmaheshrao, You may have some stray non-printable characters in you data.
Code:
SELECT INT('123') FROM SYSIBM.SYSDUMMY1

-----------
        123

SELECT INT('123' || x'00') FROM SYSIBM.SYSDUMMY1

-----------
SQL0420N  Invalid character found in a character string argument of the function "INTEGER".  SQLSTATE=22018
Try using the HEX function and see what shows up:
Code:
SELECT HEX('123' || x'00') FROM SYSIBM.SYSDUMMY1

31323300
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