Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

Go Back  dBforums > Database Server Software > Sybase > Who can help me to check the syntax?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-04-07, 23:36
winniewang winniewang is offline
Registered User
 
Join Date: Apr 2007
Posts: 63
Who can help me to check the syntax?

Hi Everyone,

I got the error below when I processed a dimension:

OLE DB error: OLE DB or ODBC error: Insufficient result space for explicit conversion of FLOAT NULL value '2.2400000000000002' to a CHAR field.

In the dimension, I have a column defined like this:
Case WHEN Weight IS NULL THEN 'Unknown' ELSE CONVERT(CHAR (5), Weight) END AS [WeightDesc]

Does it mean that there are something wrong with my query?
Who can helpe me to check it?
Your help will be appreciated.

Thanks^_^
Winnie
Reply With Quote
  #2 (permalink)  
Old 12-05-07, 06:18
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 371
Quote:
Originally Posted by winniewang
Hi Everyone,

I got the error below when I processed a dimension:

OLE DB error: OLE DB or ODBC error: Insufficient result space for explicit conversion of FLOAT NULL value '2.2400000000000002' to a CHAR field.

In the dimension, I have a column defined like this:
Case WHEN Weight IS NULL THEN 'Unknown' ELSE CONVERT(CHAR (5), Weight) END AS [WeightDesc]

Does it mean that there are something wrong with my query?
Who can helpe me to check it?
Your help will be appreciated.

Thanks^_^
Winnie

The syntax is right, but there seems to be a float value '2.2400000000000002' which cant be converted to a char(5). Either Remove the CHAR(5) or Use the round function to truncate the decimals.
Reply With Quote
  #3 (permalink)  
Old 12-05-07, 06:28
winniewang winniewang is offline
Registered User
 
Join Date: Apr 2007
Posts: 63
Actually, the "Weight" column is float, and the values are NULL, 230.0, 231.4...., I didn't find the value '2.2400000000000002', I can remove the Char(5), But If I want to convert a column like "Weight" to Char(5), are there other mothod?

Thanks^_^
Winnie
Reply With Quote
  #4 (permalink)  
Old 12-05-07, 06:40
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 371
Quote:
Originally Posted by winniewang
Actually, the "Weight" column is float, and the values are NULL, 230.0, 231.4...., I didn't find the value '2.2400000000000002', I can remove the Char(5), But If I want to convert a column like "Weight" to Char(5), are there other mothod?

Thanks^_^
Winnie

Hmm I dont remember it exactly, but floats are OS dependant I think and can vary and thats why its probably better to use numeric. You might want to do some research on that.

Try doing something this. convert(char,convert(numeric(3,2),column))

3,2 is precision and scale.

Also, read up on the convert function.
Reply With Quote
  #5 (permalink)  
Old 12-05-07, 07:01
winniewang winniewang is offline
Registered User
 
Join Date: Apr 2007
Posts: 63
Thank you for your quick reply:-)
I will reread Convert function and try you suggestion tomorrow. it is the time to go home, Thank you for your reply.

Thanks^_^
Winnie
Reply With Quote
  #6 (permalink)  
Old 12-05-07, 07:04
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 371
No Problem.

Its either 3,2 or 5,2 for your problem.
Reply With Quote
  #7 (permalink)  
Old 12-05-07, 21:43
winniewang winniewang is offline
Registered User
 
Join Date: Apr 2007
Posts: 63
Yeah, you are right. Now I can process successfully :-)

Thanks^_^
Winnie
Reply With Quote
  #8 (permalink)  
Old 12-06-07, 02:25
pdreyer pdreyer is offline
Registered User
 
Join Date: May 2005
Location: South Africa
Posts: 830
Quote:
Originally Posted by trvishi
Hmm I dont remember it exactly, but floats are OS dependant I think and can vary and thats why its probably better to use numeric. You might want to do some research on that.
For more info read:
What Every Computer Scientist Should Know About Floating-Point Arithmetic
Using the float Datatype
Reply With Quote
  #9 (permalink)  
Old 12-06-07, 02:32
winniewang winniewang is offline
Registered User
 
Join Date: Apr 2007
Posts: 63
Aha, Thanks for your detail info:-)

Thanks^_^
Winnie
Reply With Quote
  #10 (permalink)  
Old 12-06-07, 12:34
trvishi trvishi is offline
Registered User
 
Join Date: Sep 2003
Location: Switzerland
Posts: 371

Thanks pdreyer
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On