Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT

 
   Database Help (Home) -> DB2 RSS
Next:  TS5832: Urgent Need for BA - Cerner Millennium Or..  
Author Message
kg6ypx

External


Since: May 15, 2008
Posts: 3



(Msg. 1) Posted: Mon May 16, 2011 4:52 pm
Post subject: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT
Archived from groups: comp>databases>ibm-db2 (more info?)

[Running DB2 UDB version 9] Why does this SQL statement work

SELECT
CASE
WHEN A.DAILYDOWNLOADSIZE is null THEN 0
else bigint(A.DAILYDOWNLOADSIZE)
END "DAILYDOWNLOADSIZE",
CASE
WHEN A.DAILYDOWNLOADTIME is null THEN 0
else bigint(A.DAILYDOWNLOADTIME)
END "DAILYDOWNLOADTIME"
FROM
EDMPROD.MQT_STB_FACTS A

....when this one does not

SELECT DISTINCT
bigint(A.CAMID) AS "CAMID",
bigint(A.RID) AS "RID",
A.SOFTWAREVERSION,
A.MODELNUMBER,
A.MANUFACTURERID,
A.MODDATE,
A.POSTTIME,
A.DELIVERYMETHOD,
bigint(A.UPTIME ) AS "UPTIME",
bigint(A.NUMBEROFRESETSSINCELASTSWDL ) AS
"NUMBEROFRESETSSINCELASTSWDL",
bigint(A.NUMBEROFSEARCHSIGNALOSDTUNER1 ) AS
"NUMBEROFSEARCHSIGNALOSDTUNER1",
bigint(A.NUMBEROFSEARCHSIGNALOSDTUNER2 ) AS
"NUMBEROFSEARCHSIGNALOSDTUNER2",
bigint(A.NUMBEROFUSERDISKREFORMATS ) AS "NUMBEROFUSERDISKREFORMATS",
bigint(A.NUMBEROFSYSTEMDISKREFORMATS ) AS
"NUMBEROFSYSTEMDISKREFORMATS",
bigint(A.NUMBEROFRECOVEREDDISKERRORS ) AS
"NUMBEROFRECOVEREDDISKERRORS",
IPINFO,
CASE
WHEN A.DAILYDOWNLOADSIZE is null THEN 0
else bigint(A.DAILYDOWNLOADSIZE)
END "DAILYDOWNLOADSIZE",
CASE
WHEN A.DAILYDOWNLOADTIME is null THEN 0
else bigint(A.DAILYDOWNLOADTIME)
END "DAILYDOWNLOADTIME",
bigint(A.TOTALNUMBEROFDOWNLOADSSTARTED ) AS
"TOTALNUMBEROFDOWNLOADSSTARTED",
bigint(A.TOTALNUMOFCOMPLETEDDLS ) AS "TOTALNUMOFCOMPLETEDDLS",
CURRENT_DATE AS "LOAD_DATE"
FROM
EDMPROD.MQT_STB_FACTS A

I get an error SQL0420N Invalid character found in a character string
argument of the function "BIGINT". SQLSTATE=22018.

By troubleshooting the query, I confirm the culprits are the two
columns DAILYDOWNLOADSIZE and DAILYDOWNLOADTIME. Both must be casted
from character(15) to bigint.

What is the second SQL statement not working???

 >> Stay informed about: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT 
Back to top
Login to vote
Helmut Tessarek

External


Since: Jun 21, 2010
Posts: 8



(Msg. 2) Posted: Mon May 16, 2011 8:22 pm
Post subject: Re: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 16.05.11 19:52 , kg6ypx wrote:
> By troubleshooting the query, I confirm the culprits are the two
> columns DAILYDOWNLOADSIZE and DAILYDOWNLOADTIME. Both must be casted
> from character(15) to bigint.
>
> What is the second SQL statement not working???

The only reason why the second query would not work is, if someone inserted a
row in the table (after the first query) which contained incompatible characters.

This might be a dumb question, but why are you casting almost all rows to
bigint? Wouldn't it be better to create the columns as bigint?

Anyway, do a

SELECT DAILYDOWNLOADSIZE, DAILYDOWNLOADTIME FROM EDMPROD.MQT_STB_FACTS

and check, if there are any characters in the output which are not a number or
a decimal character.

--
Helmut K. C. Tessarek
DB2 Performance and Development
IBM Toronto Lab

 >> Stay informed about: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT 
Back to top
Login to vote
Lennart Jonsson

External


Since: Apr 26, 2010
Posts: 22



(Msg. 3) Posted: Tue May 17, 2011 1:25 am
Post subject: Re: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2011-05-17 01:52, kg6ypx wrote:
> [Running DB2 UDB version 9] Why does this SQL statement work
>
> SELECT
> CASE
> WHEN A.DAILYDOWNLOADSIZE is null THEN 0
> else bigint(A.DAILYDOWNLOADSIZE)
> END "DAILYDOWNLOADSIZE",
> CASE
> WHEN A.DAILYDOWNLOADTIME is null THEN 0
> else bigint(A.DAILYDOWNLOADTIME)
> END "DAILYDOWNLOADTIME"
> FROM
> EDMPROD.MQT_STB_FACTS A
>
> ...when this one does not
>
> SELECT DISTINCT
> bigint(A.CAMID) AS "CAMID",
> bigint(A.RID) AS "RID",
> A.SOFTWAREVERSION,
> A.MODELNUMBER,
> A.MANUFACTURERID,
> A.MODDATE,
> A.POSTTIME,
> A.DELIVERYMETHOD,
> bigint(A.UPTIME ) AS "UPTIME",
> bigint(A.NUMBEROFRESETSSINCELASTSWDL ) AS
> "NUMBEROFRESETSSINCELASTSWDL",
> bigint(A.NUMBEROFSEARCHSIGNALOSDTUNER1 ) AS
> "NUMBEROFSEARCHSIGNALOSDTUNER1",
> bigint(A.NUMBEROFSEARCHSIGNALOSDTUNER2 ) AS
> "NUMBEROFSEARCHSIGNALOSDTUNER2",
> bigint(A.NUMBEROFUSERDISKREFORMATS ) AS "NUMBEROFUSERDISKREFORMATS",
> bigint(A.NUMBEROFSYSTEMDISKREFORMATS ) AS
> "NUMBEROFSYSTEMDISKREFORMATS",
> bigint(A.NUMBEROFRECOVEREDDISKERRORS ) AS
> "NUMBEROFRECOVEREDDISKERRORS",
> IPINFO,
> CASE
> WHEN A.DAILYDOWNLOADSIZE is null THEN 0
> else bigint(A.DAILYDOWNLOADSIZE)
> END "DAILYDOWNLOADSIZE",
> CASE
> WHEN A.DAILYDOWNLOADTIME is null THEN 0
> else bigint(A.DAILYDOWNLOADTIME)
> END "DAILYDOWNLOADTIME",
> bigint(A.TOTALNUMBEROFDOWNLOADSSTARTED ) AS
> "TOTALNUMBEROFDOWNLOADSSTARTED",
> bigint(A.TOTALNUMOFCOMPLETEDDLS ) AS "TOTALNUMOFCOMPLETEDDLS",
> CURRENT_DATE AS "LOAD_DATE"
> FROM
> EDMPROD.MQT_STB_FACTS A
>
> I get an error SQL0420N Invalid character found in a character string
> argument of the function "BIGINT". SQLSTATE=22018.
>
> By troubleshooting the query, I confirm the culprits are the two
> columns DAILYDOWNLOADSIZE and DAILYDOWNLOADTIME. Both must be casted
> from character(15) to bigint.
>
> What is the second SQL statement not working???

This idea was posted some years ago by Troels Arvin (can't find the
original post now)

CREATE PROCEDURE castalesce_bigint_(IN strval VARCHAR(100))
LANGUAGE SQL
DETERMINISTIC
NO EXTERNAL ACTION
READS SQL DATA
BEGIN
DECLARE retval INT DEFAULT 1;
DECLARE dateval DATE;
DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET retval=-1;
SET dateval=bigint(strval);
RETURN retval;
END @

CREATE FUNCTION castalesce_bigint(strval VARCHAR(100))
RETURNS BIGINT
DETERMINISTIC
NO EXTERNAL ACTION
READS SQL DATA
BEGIN ATOMIC
DECLARE retval INT;
-- The following is needed because declaration of SQLEXECPTION handlers
-- isn't allowed in UDFs:
CALL castalesce_bigint_(strval);
GET DIAGNOSTICS retval = DB2_RETURN_STATUS;
IF retval = 1 THEN RETURN bigint(strval);
ELSE RETURN NULL;
END IF;
END @

There might be an error or two in there but the idea should hold (the
original thread was about date). Now:

select DAILYDOWNLOADSIZE, DAILYDOWNLOADTIME
from EDMPROD.MQT_STB_FACTS
where castalesce_bigint(DAILYDOWNLOADSIZE) is null
or castalesce_bigint(DAILYDOWNLOADTIME) is null

reveals what cannot be casted.

However, since you are doing a full table scan in your first query my
guess is that the error comes from some of the casts that's in q2 but
not in q1.

/Lennart
 >> Stay informed about: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT 
Back to top
Login to vote
Lennart Jonsson

External


Since: Apr 26, 2010
Posts: 22



(Msg. 4) Posted: Tue May 17, 2011 3:25 am
Post subject: Re: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2011-05-17 06:42, Lennart Jonsson wrote:
[...]
> select DAILYDOWNLOADSIZE, DAILYDOWNLOADTIME
> from EDMPROD.MQT_STB_FACTS
> where castalesce_bigint(DAILYDOWNLOADSIZE) is null
> or castalesce_bigint(DAILYDOWNLOADTIME) is null
>

If DAILYDOWNLOADSIZE is nullable:

where ( castalesce_bigint(DAILYDOWNLOADSIZE) is null and
DAILYDOWNLOADSIZE is not null )
or ( ...

/Lennart
 >> Stay informed about: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT 
Back to top
Login to vote
kg6ypx

External


Since: May 15, 2008
Posts: 3



(Msg. 5) Posted: Tue May 17, 2011 11:38 am
Post subject: Re: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

I was losing my mind over this so I made a simple change in my staging
table (EDMPROD.MQT_STB_FACTS).

Instead of typing the columns as characters and then casting them as
bigint, I dropped and recreated my table with the datatypes set to
BIGINT(Cool.

I removed the castings from my SQL statement and the error went away.

Go figure..........
 >> Stay informed about: SQLCODE: -420, SQLSTATE: 22018, SQLERRMC: BIGINT 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
db2 error ( Agent not allocated, sqlcode = -1225 ) - Hi, We are getting following errors in diaglog. We have 4096 value as MAXAGENTS and 512 for maxuproc I am confused as which value we are hitting. are we hitting OS ( maxuproc ) value or MAXAGENTS. is there anything else i am missing which need to be..

CLI0111E Numeric value out of range. SQLSTATE=22003 - hi, we use Toplink (TopLink - 4.6.0 (Build 417) with a DB2 Database 7.2. i know really old versions, but we could change to e newer one ;-) Sometimes we got some problems with update or insert statements -- numeric value out of range. The SQL statement...

Alter Table causes SQL0901N ( SQLSTATE=58004 ) - Hi, I am trying to run the following SQL through the DB2 command line for version 9.1.0: alter table SCHEMA.TABLE1 drop column A; alter table SCHEMA.TABLE2 alter column B set data type decimal(15,4); * Column B was Integer. The commands both..

CLI0109E String Data Right Truncation SQLSTATE=22001 - We are on DB2, AIX fixpak 14 This error happens when running PeopleSoft PeopleCode Application Engine process. I have checked other posts out here and it seems like others who have reported it seem to be saying their is a problem with the way DB2 is..

DB2 UDB LUW 8.2:clp 32 bit connect to 64 bit engine - Environment: DB2 UDB LUW (AIX) 8.2 Database instance: test migration to 64 bit Clients: 32 bit, embedded sql, db2 clp When PATH/LIBPATH point to the 32 lib environment (/usr/opt/db2_08_01/bin and (/usr/opt/db2_08_01/lib) db2..
   Database Help (Home) -> DB2 All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]