RE: The IIf function

2006-05-02 Thread Everett, Al \(NIH/NIGMS\) [C]
It used to be, but is not so anymore, that IIF() was slower than
cfifcfelse/cfif.

It also used to be true, although I don't think it is any more, that all
of the expressions in an IIF() are evaluated even if not used. Not true
of cfif.

I know in older versions this would cause an error:

#iif(isDefined(myVar),myVar,'undefined'))#

However, this wouldn't:

cfif isDefined(myVar)
#myVar#
cfelse
undefined
/cfif

Yeah, I thought it was pretty goofy too.

I only ever really use iif() in situations like this:

select name=chosenOption
cfloop query=qOptions
option value=#qOptions.option_id#
#iif(qOptions.option_id eq
variables.default_option_id,'selected','')##qOptions.option_name#/
option
/cfloop
/select

I think it's very bad style to put CF tags inside HTML tags.



-Original Message-
From: Matthew Chambers [mailto:[EMAIL PROTECTED] 
Sent: Monday, May 01, 2006 7:40 PM
To: CF-Talk
Subject: The IIf function

Hi all,

Am I correct in saying that the IIf function and the cfif tag work
differently on the following scenerio. In the CFIF tag, when the CFIF
fails it will jump over the code which follows until a CFELSEIF,
CFELSE or CFIF.
Here's an example:
--
CFIF
The cfif failed so this text is not run. More to the point this code is
not run, cfqueryKILL DATABASE/cfquery /CFIF
---
Where as with the IIf function, CF will still test that the code for
both the true and false cases will work? This is dumb, because the whole
point for an IF is to check that you will have everything you need to
run the code when it returns true.
:::CFIF eg:::
cfif IsDefined(foo
cfset foo = foo+1
/cfif
:::IIf eg:::
Iif(IsDefined(foo),DE(foo=foo+1),DE('whatever'))

Any thoughts?
Cheers




~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239234
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


Re: The IIf function

2006-05-01 Thread Douglas Knudsen
IIF() is shorthand replacement for IF/THEN/ELSE.  Other langs have
IIF() too, eh?

Thus
cfif foo IS 5
   foo is 5
cfelse
   foo is not 5
/cfif

is equivalent to

IIF(foo IS 5, 'foo is 5', 'foo is not 5')

*note...mind the quotes!  ' is double quote followed by single quote

DK

On 5/1/06, Matthew Chambers [EMAIL PROTECTED] wrote:
 Hi all,

 Am I correct in saying that the IIf function and the cfif tag work 
 differently on the following scenerio. In the CFIF tag, when the CFIF fails 
 it will jump over the code which follows until a CFELSEIF, CFELSE or CFIF.
 Here's an example:
 --
 CFIF
 The cfif failed so this text is not run. More to the point this code is not 
 run, cfqueryKILL DATABASE/cfquery
 /CFIF
 ---
 Where as with the IIf function, CF will still test that the code for both the 
 true and false cases will work? This is dumb, because the whole point for an 
 IF is to check that you will have everything you need to run the code when it 
 returns true.
 :::CFIF eg:::
 cfif IsDefined(foo
 cfset foo = foo+1
 /cfif
 :::IIf eg:::
 Iif(IsDefined(foo),DE(foo=foo+1),DE('whatever'))

 Any thoughts?
 Cheers


 

~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239217
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations  Support: http://www.houseoffusion.com/tiny.cfm/54


RE: OT - IIF function in Access

2000-05-05 Thread Paul Wakefield

I think you've got the SUM and IIF nested the wrony way 'round - try

SUM(IIF(site_date  {d '2000-04-27'}, totalbirds, 0))

 -Original Message-
 From: Deanna L. Schneider [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, May 04, 2000 10:07 PM
 To: [EMAIL PROTECTED]
 Subject: Re: OT - IIF function in Access
 
 
 Thanks, John, but that's not really the problem, I don't think.
 
 The query works if I use constants like this.
 
 
 cfquery name="pullcount" datasource="#dbvar#"
 SELECT  IIF(10, sum(totalbirds), 0) AS weekbirds,
   IIF(10, sum(totalbirds), 0) AS monthbirds,
   IIF(10, sum(totalbirds), 0)AS yearbirds,
 site.per_id,
   person.fname,
   person.lname
 FROM sighting, site, person
 WHERE sighting.site_id = site.site_id
 AND  site.per_id = person.per_id
 GROUP BY site.per_id, person.fname, person.lname
 /cfquery
 
 
 But if I try to throw a variable in thereit doesn't work. 
 More thoughts?
 -d
 
 
 
 [Microsoft][ODBC Microsoft Access Driver] Syntax error 
 (missing operator) in
 query expression 'IIF(site_date  #4/27/2000# sum(totalbirds), 0)'.
 
 
 SQL = "SELECT IIF(site_date  {d '2000-04-27'} sum(totalbirds), 0) AS
 weekbirds, IIF(10, sum(totalbirds), 0) AS monthbirds, IIF(10,
 sum(totalbirds), 0)AS yearbirds, site.per_id, person.fname, 
 person.lname
 FROM sighting, site, person WHERE sighting.site_id = site.site_id AND
 site.per_id = person.per_id GROUP BY site.per_id, person.fname,
 person.lname"
--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



Re: OT - IIF function in Access

2000-05-04 Thread John N Westerlund

I usually see the query coded as:

AND site_date  #date1#
AND site_date  #now()#

Primitive I know, but tried and true :-)


-Original Message-
From: Deanna L. Schneider [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Date: Thursday, May 04, 2000 3:10 PM
Subject: OT - IIF function in Access


Hi folks, this is a bit OT, but I thought there might be a better way to do
what's not working in CF anyway, so here it is:

I have the following code:
cfset week = #now()# - #createtimespan(7, 0, 0, 0)#
cfset month = #now()# - #createtimespan(30, 0, 0, 0)#
cfset year = #now()# - #createtimespan(365, 0, 0, 0)#

cfquery name="pullcount" datasource="#dbvar#"
SELECT  SUM(totalbirds) AS weekbirds,
  site.per_id, person.fname, person.lname
FROM sighting, site, person
WHERE sighting.site_id = site.site_id
AND  site.per_id = person.per_id
AND  site.site_date between #now()# AND #createodbcdate(month)#
GROUP BY site.per_id, person.fname, person.lname
/cfquery

It works fine, but what I want to do is pull the bird counts for the week,
the month and the year. I think I should be able to do it with something
like:
cfquery name="pullcount" datasource="#dbvar#"
SELECT  IIF(site.site_date between #now()# AND #createodbcdate(month)#,
SUM(totalbirds) AS monthbirds, 0),
  site.per_id, person.fname, person.lname
FROM sighting, site, person
WHERE sighting.site_id = site.site_id
AND  site.per_id = person.per_id
AND  GROUP BY site.per_id, person.fname, person.lname
/cfquery

But, what I get is this lovely error:
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in
query expression 'IIF(site.site_date between #5/4/2000 14:04:35# AND
#4/4/2000#, SUM(totalbirds) AS monthbirds, 0)'.

Help?

TIA,
Deanna


Deanna Schneider
Interactive Media Developer
UWEX Cooperative Extension Electronic Publishing Group
103 Extension Bldg
432 N. Lake Street
Madison, WI 53706
(608) 265-7923




--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



Re: OT - IIF function in Access

2000-05-04 Thread Deanna L. Schneider

Thanks, John, but that's not really the problem, I don't think.

The query works if I use constants like this.


cfquery name="pullcount" datasource="#dbvar#"
SELECT  IIF(10, sum(totalbirds), 0) AS weekbirds,
  IIF(10, sum(totalbirds), 0) AS monthbirds,
  IIF(10, sum(totalbirds), 0)AS yearbirds,
site.per_id,
  person.fname,
  person.lname
FROM sighting, site, person
WHERE sighting.site_id = site.site_id
AND  site.per_id = person.per_id
GROUP BY site.per_id, person.fname, person.lname
/cfquery


But if I try to throw a variable in thereit doesn't work. More thoughts?
-d



[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in
query expression 'IIF(site_date  #4/27/2000# sum(totalbirds), 0)'.


SQL = "SELECT IIF(site_date  {d '2000-04-27'} sum(totalbirds), 0) AS
weekbirds, IIF(10, sum(totalbirds), 0) AS monthbirds, IIF(10,
sum(totalbirds), 0)AS yearbirds, site.per_id, person.fname, person.lname
FROM sighting, site, person WHERE sighting.site_id = site.site_id AND
site.per_id = person.per_id GROUP BY site.per_id, person.fname,
person.lname"





Deanna Schneider
Interactive Media Developer
UWEX Cooperative Extension Electronic Publishing Group
103 Extension Bldg
432 N. Lake Street
Madison, WI 53706
(608) 265-7923



--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.



Re: OT - IIF function in Access

2000-05-04 Thread David E. Crawford

Missing comma in this piece (right before sum(totalbirds).  Change that and
see what happens.


SELECT IIF(site_date  {d '2000-04-27'} sum(totalbirds), 0) AS
weekbirds, IIF(10, sum(totalbirds), 0) AS monthbirds, IIF(10,
sum(totalbirds), 0)AS yearbirds, site.per_id, person.fname, person.lname
FROM sighting, site, person WHERE sighting.site_id = site.site_id AND
site.per_id = person.per_id GROUP BY site.per_id, person.fname,
person.lname

- Original Message -
From: Deanna L. Schneider [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, May 04, 2000 20:06
Subject: Re: OT - IIF function in Access


 Thanks, John, but that's not really the problem, I don't think.

 The query works if I use constants like this.


 cfquery name="pullcount" datasource="#dbvar#"
 SELECT  IIF(10, sum(totalbirds), 0) AS weekbirds,
   IIF(10, sum(totalbirds), 0) AS monthbirds,
   IIF(10, sum(totalbirds), 0)AS yearbirds,
 site.per_id,
   person.fname,
   person.lname
 FROM sighting, site, person
 WHERE sighting.site_id = site.site_id
 AND  site.per_id = person.per_id
 GROUP BY site.per_id, person.fname, person.lname
 /cfquery


 But if I try to throw a variable in thereit doesn't work. More
 thoughts?
 -d



 [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
 operator) in
 query expression 'IIF(site_date  #4/27/2000# sum(totalbirds), 0)'.


 SQL = "SELECT IIF(site_date  {d '2000-04-27'} sum(totalbirds), 0) AS
 weekbirds, IIF(10, sum(totalbirds), 0) AS monthbirds, IIF(10,
 sum(totalbirds), 0)AS yearbirds, site.per_id, person.fname, person.lname
 FROM sighting, site, person WHERE sighting.site_id = site.site_id AND
 site.per_id = person.per_id GROUP BY site.per_id, person.fname,
 person.lname"




 
 Deanna Schneider
 Interactive Media Developer
 UWEX Cooperative Extension Electronic Publishing Group
 103 Extension Bldg
 432 N. Lake Street
 Madison, WI 53706
 (608) 265-7923



 
 --
 Archives: http://www.eGroups.com/list/cf-talk
 To Unsubscribe visit
 http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk
 or send a message to [EMAIL PROTECTED] with
 'unsubscribe' in the body.


--
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=listsbody=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.