Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfif syntax problem

Status
Not open for further replies.

EAS

Programmer
May 21, 2001
25
GB
Dear All
Please help - I have a variable called left_select that contains, for example, '5','9','2'. I have a query (ExistIntQ.InterestType) that contains a 5 and a 9. If the contents of ExistIntQ.InterestType are all in left_select then I do nothing. If there are items missing (the number 2 in this example) I want to insert details about 2 into my SQL database. If ExistIntQ.InterestType has items not included in left_select then I need to update my SQL with an end date. I have tried loads of variations on my syntax but am failing miserably eg:

<cfif ExistIntQ.PersonRef eq #form.pref# and #form.left_select# eq #ExistIntQ.InterestType#>
1 do nothing<br>
</cfif>

<cfif #ExistIntQ.PersonRef# eq #form.pref# and (#ExistIntQ.InterestType# contains #form.left_select# neq True)>
2 insert interest
</cfif>

Thanks in advance for any help offered
Liz

 
I'd cycle through something like this...

Code:
<CFSET loopStatus=0>
<CFSET loopList=&quot;&quot;>
<CFLOOP list=&quot;#ExistIntQ.InterestType#&quot; index=&quot;i&quot;>
 <CFIF ListFind(left_select,i) eq 0>
  <CFSET loopStatus=1>
  <CFSET loopList=listAppend(loopList,i)>
 </CFIF>
</CFLOOP>

loopList should now contain all items in ExistIntQ.InterestType not contained in left_select...

Send all contributions in gratitude to the Insomnia Relief Fund c/o Tony Hicks ;) ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Thanks for your prompt reply
Unfortunately looplist gave me the 5 not the 2 from ExistIntQ.InterestType - I've changed my data to check exactly what it's getting and it's always the first entry in the list
Liz
 
Code:
<CFSET eiq=&quot;5,3,2,8,7,1&quot;>
<CFSET left_select=&quot;5,2,7,1&quot;>
<CFSET loopStatus=0>
<CFSET loopList=&quot;&quot;>
<CFLOOP list=&quot;#EIQ#&quot; index=&quot;i&quot;>
 <CFIF ListFind(left_select,i) eq 0>
  <CFSET loopStatus=1>
  <CFSET loopList=listAppend(loopList,i)>
 </CFIF>
</CFLOOP>

<CFOUTPUT>#loopList#</CFOUTPUT>

returns what? ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
The right answer! 3,8 - I have repeated your code exactly
<CFSET LizQ=&quot;#ExistIntQ.InterestType#&quot;>
<CFSET Lizleft=&quot;#left_select#&quot;>
<CFSET loopStatus=0>
<CFSET loopList=&quot;&quot;>
<CFLOOP list=&quot;#LizQ#&quot; index=&quot;i&quot;>
<CFIF ListFind(#Lizleft#,i) eq 0>
<CFSET loopStatus=1>
<CFSET loopList=listAppend(loopList,i)>
</CFIF>
<cfoutput>liz looplist #looplist#<br></cfoutput>
</CFLOOP>
and I still just get the first number!!!!!!!! It must be something with my data - thanks for the help, it's much appreciated.
Liz
 
Have you tried ouputting just &quot;&quot;<CFOUTPUT><PRE>#ExistIntQ.InterestType#</PRE></CFOUTPUT>&quot; (with the quotes so you know if there's extra spaces? ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Also I just thought about this.. wrap the confirm code in:

Code:
<CFIF ExistIntQ.InterestType neq left_select>
 ...code here...
</CFIF>

so if it matches exactly the loop code is ignored.. faster processing..

Happy Thanksgiving

Tony [b]ALFII.com[/b]
[URL unfurl="true"]http://www.alfii.com[/URL]
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Thanks Tony - It was my data - ExistIntQ.InterestType wasn't a true comma delimited list. I added <CFSET LizQ=&quot;#quotedvaluelist(ExistIntQ.InterestType)#&quot;> to my code and it worked. Thanks for the last 2 suggestions though
Liz
 
Hey man, no problem ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top