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 handle this db2 sql error?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-15-11, 01:19
vipul aggarwal vipul aggarwal is offline
Registered User
 
Join Date: Dec 2011
Posts: 4
Red face How to handle this db2 sql error?

I AM EXPERIENCING AN ERROR WHILE PERFORMING A FUNCTION ON A COULMN DATA OF DATA TYPE VARCHAR. THE FUNCTION I AM PERFORMING IS:
1: CONVERTING INTO DOUBLE
2: OPERATING A SUM FUNCTION
3: USING A COALESCE FUNCTION BECAUSE SOME FIELDS ARE NULL IN THAT COLUMN

THE MESSAGE I AM RECEIVING IS:

Message: Routine "SYSFUN.DOUBLE" (specific name "CHARTODOUBLE") has returned an error SQLSTATE with diagnostic text "SYSFUN:11".

SOMEBODY PLEASE HELP ME OUT.
MY WHOLE PROGRESS IS STUCK BECAUSE OF THIS.
Reply With Quote
  #2 (permalink)  
Old 12-15-11, 02:02
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
could you publish the function - the complete error message and indicate if this happened with specific data or at random
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #3 (permalink)  
Old 12-15-11, 02:36
vipul aggarwal vipul aggarwal is offline
Registered User
 
Join Date: Dec 2011
Posts: 4
Quote:
Originally Posted by przytula_guy View Post
could you publish the function - the complete error message and indicate if this happened with specific data or at random
this is the query:

FOR B3 AS SELECT MSISDN_NO, SUM(DOUBLE(VOICE_DECREMENT)) AS VODEC, SUM(DOUBLE(GPRS_DECREMENT)) AS GPDEC,SUM(DOUBLE(SMS_DECREMENT)) AS SMDEC FROM TEMP_IN_DECREMENT GROUP BY MSISDN_NO
DO
IF VOICE_DECREMENT IS NULL
THEN
SET lv_VODEC = 0;
ELSE
SET lv_VODEC = VODEC;
SET lv_GPDEC = GPDEC;
SET lv_SMDEC = SMDEC;
SET lv_TODEC = lv_VODEC + lv_GPDEC + lv_SMDEC;
UPDATE USAGE_DATA SET (VOICE_DECREMENT, GPRS_DECREMENT, SMS_DECREMENT, TOTAL_DECREMENT) = (lv_VODEC, lv_GPDEC, lv_SMDEC, lv_TODEC) WHERE MSISDN = B3.MSISDN_NO;
END FOR;
Reply With Quote
  #4 (permalink)  
Old 12-15-11, 02:47
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
just publishing the query does not help anybody
try to publish as much as possible details, so we can TRY to understand what is going on...
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
Reply With Quote
  #5 (permalink)  
Old 12-15-11, 02:59
vipul aggarwal vipul aggarwal is offline
Registered User
 
Join Date: Dec 2011
Posts: 4
Quote:
Originally Posted by przytula_guy View Post
just publishing the query does not help anybody
try to publish as much as possible details, so we can TRY to understand what is going on...
i am trying to update a table named USAGE_DATA with the fields named in the bracket in the query with datatype as DOUBLE.
the TEMP_IN_DECREMENT table has the same column names but with a different datatype as VARCHAR.

so i have to update the data_usage table with this data converting it into double and performing a function sum side by side...

but i am not able to perform these functions.. this is all i can elaborate.. kindly manage
Reply With Quote
  #6 (permalink)  
Old 12-15-11, 06:08
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Quote:
Originally Posted by przytula_guy View Post
could you publish the function - the complete error message and indicate if this happened with specific data or at random
Still, you didn't publish the complete error message.
Where is difficulty for you?

If you want to save your time and work,
I also save my time and work to answer your question.


Anyway, there is an IF statement in your code...
Quote:
IF VOICE_DECREMENT IS NULL
...
What is VOICE_DECREMENT?

It is not declared nor in SELECT list.

Last edited by tonkuma; 12-15-11 at 07:13. Reason: Add last sentence "It is not declared nor in SELECT list."
Reply With Quote
  #7 (permalink)  
Old 12-15-11, 09:20
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Different question: why are you doing this processing in a loop in your application? You could push-down everything into a single UPDATE statement. That should perform much better, too.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #8 (permalink)  
Old 12-15-11, 09:51
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
Yes! Stolze.

I thought a MERGE statement might be better.

More to said,
the table name TEMP_IN_DECREMENT suggested that it may be a temporary table.
If so, the process to popurate into the temporary table might be able to put into an UPDATE or a MERGE statement, too.

Last edited by tonkuma; 12-15-11 at 11:16.
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