Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

The value coldfusion.sql.QueryTable cannot be converted to a number

New Here ,
Sep 14, 2010 Sep 14, 2010

Hi,

I have two queries, in two different functions, which both return the SUM of a column, depending on the values from the arguments

I need to subtract query 2 from query 1.

The arguments for both queries are passed using the CreateObject Function

<cfset qry1 = createObject("component","components.adminobjects").Func1(#argument1#,#argument2#)>

<cfset qry2 =  createObject("component","components.adminobjects").Func1(#argument1#,#argument2#)>

The queries do get executed accordingly and returns the results accordingly.

The problem occurs when I try to calculate by subtracting the 2nd query form the 1st.

So, to get the results that I need, this is what I do:

<cfset results = "#qry1.sum#" - "#qry1.sum2#">

<cfoutput>#results#</cfoutput>

When I do this, it says:

The  value coldfusion.sql.QueryTable cannot be converted to a number

I do not get it, this is because when I output #qry1.sum# or #qry1.sum2# I do get the right figures and they are numbers, but when I do some math on them, I get the error.

Any ideas?

Thank you.

3.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Sep 14, 2010 Sep 14, 2010

Assuming that the qry1 object has a columns named "sum1" and "sum2"  try :

<cfset results = Val(qry1.sum1) - Val(qry1.sum2)>

Also note that "sum" is a reserved word, try changing the column "sum" to "sum1".

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec173d0-7fff.html

Translate
New Here ,
Sep 14, 2010 Sep 14, 2010

Just want correct something

<cfset qry2 =   createObject("component","components.adminobjects").Func1(#argument1#  ,#argument2#)>

goes to Func2 not to Func1. (I copied and pasted & forgot to edit that)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 14, 2010 Sep 14, 2010

Assuming that the qry1 object has a columns named "sum1" and "sum2"  try :

<cfset results = Val(qry1.sum1) - Val(qry1.sum2)>

Also note that "sum" is a reserved word, try changing the column "sum" to "sum1".

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec173d0-7fff.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2010 Sep 14, 2010

Thank Bob,

I did both and it worked.

I looked for the Val function in the main function list in CF 8's Documentation, but did not find it. Shouldn't it be there? To find it, you'd first have to go to the "Conversion Functions".

I've just learnt a new function.

Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 14, 2010 Sep 14, 2010

The function is listed in the online CF8 documentation on the page linked below.

http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions-pt0_01.html

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 14, 2010 Sep 14, 2010
LATEST

Found it after scrolling.

Just realized that the reason why I could not find was that I had my 'match case' enabled in firefox's find, thus 'val' was not 'Val'.

Thank you.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources