Hi thanks for the replies I used structKeyExists as per lyndon's recommendation, but the page throws an error if there is page.cfm without any sectorid parameter
<cfinclude template = "header.cfm">
<cfquery name="qNames" datasource="sales">
select * from COMPANY, sector
where COMPANY.sectorid = sector.sectorid
<cfif structKeyExists(url,"sectorID")>
and sector.sectorid = #url.sectorid#
</cfif>
</cfquery>
<cfquery name="sNames" datasource="sales">
select * from COMPANY, sector
where <cFIF IsDefined('url.sectorID')>
sector.sectorid = #url.sectorid#
</cfif>
</cfquery>
<CFQUERY name="sector" datasource="sales">
SELECT sectorId, sector
FROM sector
ORDER BY sector
</CFQUERY>
but the page throws an error if there is page.cfm without any sectorid parameter |
If you ever get an error you want help with, don't just tell us you got an error, tell us what the error is. Inded paying close attention to the error message will generally tell you where you're going wrong.
Also, look at this:
<cfquery name="sNames" datasource="sales"> select * from COMPANY, sector where <cFIF IsDefined('url.sectorID')> sector.sectorid = #url.sectorid# </cfif> </cfquery> |
If there is no sectorid, what SQL will that create?
The SQL being sent to the DB should be part of the error message, btw...
--
Adam