?
Solved

Error 7354 on SQL server

Posted on 2003-03-27
4
Medium Priority
?
2,286 Views
Last Modified: 2007-12-19
I am using this SQL Query

SELECT c.ID, d.*
FROM Company c RIGHT OUTER JOIN
OPENQUERY(Dynamics,
'SELECT h.CUSTNMBR, s.ITEMNMBR, MONTH(h.DOCDATE) AS CubeMonth,
SUM(s.QTYTOINV) AS CubeQty, SUM(s.XTNDPRCE) AS CubeDollar
FROM SOP30200 h, SOP30300 s, IV00101 i
WHERE h.SOPNUMBE = s.SOPNUMBE
GROUP BY h.CUSTNMBR, s.ITEMNMBR, MONTH(h.DOCDATE)') d
ON c.CustNmbr = d.CUSTNMBR

and I ve got this message :

Server: Msg 7354, Level 16, State 1, Line 1
OLE DB provider 'MSDASQL' supplied invalid metadata for column 'CubeQty'. The precision exceeded the allowable maximum.
OLE DB error trace [Non-interface error:  Column 'CubeQty' (ordinal 4) of object 'SELECT h.CUSTNMBR, s.ITEMNMBR, MONTH(h.DOCDATE) AS CubeMonth,
SUM(s.QTYTOINV) AS CubeQty, SUM(s.XTNDPRCE) AS CubeDollar
FROM SOP30200 h, SOP30300 s, IV00101 i
WHERE h.SOPNUMBE = s.SOPNUMBE
GROUP BY h.CUSTNMBR, s.ITEMNMBR, MONTH(h.DOCDATE)' reported an unsupported value for PRECISION of 74].


If try to get rid of "SUM(s.QTYTOINV) AS CubeQty", I have the same error but on CubeDollar
If I try to use MAX instead of SUM, I have no error

Dynamics is a Persavise SQL server (btrieve Data)


Can someone help me, Please
0
Comment
Question by:mbelouara
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 13

Accepted Solution

by:
ispaleny earned 2000 total points
ID: 8221471
A) MS SQL Server support precision up to 38, so 74 is not supported.
Agregate Sum() increased precision. It is probably a default behavior of Pervasive SQL server.

SELECT c.ID, d.*
FROM Company c
RIGHT OUTER JOIN
OPENQUERY(Dynamics,
'SELECT h.CUSTNMBR, s.ITEMNMBR, MONTH(h.DOCDATE) AS CubeMonth
,CAST(SUM(s.QTYTOINV) AS DECIMAL(38,16)) AS CubeQty
,CAST(SUM(s.XTNDPRCE) AS DECIMAL(38,16)) AS CubeDollar
FROM SOP30200 h, SOP30300 s, IV00101 i
WHERE h.SOPNUMBE = s.SOPNUMBE
GROUP BY h.CUSTNMBR, s.ITEMNMBR, MONTH(h.DOCDATE)') d
ON c.CustNmbr = d.CUSTNMBR

B) Or it is a bug.
Something like http://dbforums.com/arch/26/2002/3/321667
0
 
LVL 13

Expert Comment

by:ispaleny
ID: 8224778
How it works ?
0
 

Author Comment

by:mbelouara
ID: 8226477
Thanks Ispaleny.

"CAST" didn't work but you gave me a good clue
I just changed cast for convert
I have now CONVERT(SUM(s.QTYTOINV),SQL_DOUBLE) AS CubeQty, CONVERT(SUM(s.XTNDPRCE),SQL_DOUBLE) AS CubeDollar

Thanks a lot

You save my life

0
 
LVL 13

Expert Comment

by:ispaleny
ID: 8230978
I downloaded Pervasive SQL server help file and I found nothing about converting, only that CAST is a reserved word. Then I sought thrue www.pervasive.com and I found 1 use of SELECT CAST(... AS ...).
So the correct syntax is CONVERT(X,SQL_DOUBLE).

MSSQLSERVER also increases precision for SUM() function to prevent an overflow.

This is a very rare case, when an error reported by ODBC meams exactly the same thing it says.

Best regards, Ivo Spaleny.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question