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

query of query issue

Advisor ,
Jul 18, 2012 Jul 18, 2012

HI All,

I am using oracle 11 and CF 10.

How can I handle a division calculation in a query of query when the divider is zero?

<cfquery name="calculateDiv" dbtype="query">

    SELECT 25/0 AS value_1, 35/5 as value_2, 40/0 as value_3

    FROM dual

</cfquery>

I cannot use decode, NULLIF.

Thanks!

1.0K
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
LEGEND ,
Jul 18, 2012 Jul 18, 2012

The short version is that you can't.

I'd try to get the DB to do it instead, if poss: QoQ ain't that good at anything more than the basics.

--

Adam

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 ,
Jul 18, 2012 Jul 18, 2012

Like Adam said, try to do it in the db.  if you cannot, then instead of the QofQ just do a CFLOOP over the resultset - that will allow you to use any CF code you want to determine which values are null, and replace whatever resultset values with a new calculated value.

-reed

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
Advisor ,
Jul 18, 2012 Jul 18, 2012

I cannot do it in the DB but this is a good idea, thanks!

The issue is i am join two queries in one query.

Best,

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
LEGEND ,
Jul 18, 2012 Jul 18, 2012
LATEST

Why is joining two queries an issue?

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