Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cfif statment inside query

Posted on 2011-02-16
6
Medium Priority
?
520 Views
Last Modified: 2012-05-11
so im looping through my query...

<cfoutput>
            <cfloop query="SQL">
<td>#Value_1#</td>
<td>#Value_2#</td>
<td>#Value_3#</td>
<td>  #Value_4#  </td>  <!-- What i want to do here is for value 5 -->
<td><cfif  #Value_4#.currentrow  = 'X'> #Value_5#  <cfelse> #Value_6#</td>
</cfif>
</tr>
</cfloop>
</cfoutput>
so I need to check Value_4 for each row to see if its X. If it is display value 5 for that row , if not display  Value 6

Please Help

0
Comment
Question by:plusone3055
[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
6 Comments
 
LVL 19

Expert Comment

by:Jones911
ID: 34912851
OK and whats failing?
0
 
LVL 1

Expert Comment

by:medsoos
ID: 34912916
Try using 'is' instead of the equal (=) sign.
0
 
LVL 3

Accepted Solution

by:
sajayc earned 2000 total points
ID: 34913021
Hi,

Couple of things:
- You don't need the .currentrow and the closing </cfif> needs to be inside the td.
- The correct operator inside the if statement is eq for =.

Code below should work.

<cfoutput>
            <cfloop query="SQL">
<td>#Value_1#</td>
<td>#Value_2#</td>
<td>#Value_3#</td>
<td>  #Value_4#  </td>  <!-- What i want to do here is for value 5 -->
<td><cfif  Value_4 eq "X"> #Value_5# <cfelse>#Value_6#</cfif> </td>
</tr>
</cfloop>
</cfoutput>

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 63

Expert Comment

by:Zvonko
ID: 34913029
Get that end of table cell out of cfelse branch:

<td>
<cfif  #Value_4# EQ  'X'>
   #Value_5#  
<cfelse>
   #Value_6#
</cfif>
</td>
</tr>

And remove the .currentrow from column value in the cfif compare.

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 34913034
Sorry, too slow typing.
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 34913467
so I need to check Value_4 for each row to see if its X. If it is display value 5 for that row , if not display  Value 6

If your value_4 and X are strings, then use compare function

<td>
<cfif NOT compareNoCase('#value_4#','X')>
	#value_5#
<cfelse>
	#value_6#
</cfif>
</td>
</tr>

Open in new window


0

Featured Post

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

718 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