quote:
Originally posted by:
BKBK
I tried your code and I am getting the following error:
Of course, you did. My bad. I carried the SQL-Server function
CHARINDEX() over to Coldfusion QoQ, where it is unknown. I have
replaced it in the above code with something more in tune with QoQ.
Thanks so much. Your code did the trick. I made one minor
adjustment. Here is the final code:
<cfquery name="getPriceDiscounts"
datasource="#DSource#">
SELECT *
FROM priceDiscounts
WHERE expdate > #Now()# AND type = 'P'
</cfquery>
<!--- discounts for which range=ALL --->
<cfquery name="getAll" dbtype="query">
SELECT *
FROM getPriceDiscounts
WHERE range = 'ALL'
</cfquery>
<!--- discounts for which range <> ALL and
getPage.Location contains range--->
<cfquery name="getRange" dbtype="query">
SELECT *
FROM getPriceDiscounts
WHERE range <> 'ALL' and '#getPage.Location#' like
'%'+range+'%'
</cfquery>
<!--- discounts for which range <> ALL and
getPage.Location does not contain range--->
<cfquery name="getOutsideRange" dbtype="query">
SELECT *
FROM getPriceDiscounts
WHERE range <> 'ALL' and '#getPage.Location#' not like
'%'+range+'%'
</cfquery>
<CFIF getALL.RecordCount neq 0>
<div>
<p><strong>getALL
discounts:</strong></p>
<!--- loop across getALL query and display the amounts
--->
<cfoutput query="getALL">
<cfset sale = getPage.field7 * getALL.discount>
<cfset weight = getPage.field7 - sale>
<cfset dollars = ListFirst(weight, ".")>
<cfset cents =
ListLast(NumberFormat(weight,"9999.99"),".")>
$#val(dollars)#.#cents#<br>
</cfoutput>
</div>
</CFIF>
<CFIF getRange.RecordCount neq 0 AND getALL.RecordCount eq
0>
<div>
<p><strong>getRange
discounts:</strong></p>
<!--- loop across getRange query and display the amounts
--->
<cfoutput query="getRange">
<cfset sale = getPage.field7 * getRange.discount>
<cfset weight = getPage.field7 - sale>
<cfset dollars = ListFirst(weight, ".")>
<cfset cents =
ListLast(NumberFormat(weight,"9999.99"),".")>
$#val(dollars)#.#cents#<br>
</cfoutput>
</div>
</CFIF>
<CFIF getOutsideRange.RecordCount neq 0 AND
getALL.RecordCount eq 0 AND getRange.RecordCount eq 0>
<div>
<p><strong>getOutsideRange
discounts:</strong></p>
<!--- loop across getOutsideRange query and display the
amounts --->
<cfoutput query="getOutsideRange">
<cfset weight = getPage.field7>
<cfset dollars = ListFirst(weight, ".")>
<cfset cents =
ListLast(NumberFormat(weight,"9999.99"),".")>
$#val(dollars)#.#cents#<br>
</cfoutput>
</div>
</CFIF>