Re: CF8 cfexecute Problem
Hmmm... This runs via cfhttp url=http://www.myserverdev.com/ipi_grabber/get.cfm?w=#xWaitDocTime#s=#lcase(attributes.website)# result=grabResult /. So the caller is on a different server than the webshot program. The caller of the CF program is really irrelevant here. It's the user account used to run the CF program that matters. Wherever get.cfm is, that's the user account you're worried about. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346476 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: CF8 cfexecute Problem
That worked! Thank you so much! Is it because both the program Webshot and ColdFusion were installed under my user account? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346477 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Resetting cached components
I've got a hypothetical situation that entered into me little brain this morning that I thought I'd ping the group on for answers. Let's say I've got an object cached in the application scope. The call to this CFC is used throughout the site, which gets a lot of traffic. Everything inside the CFC is var scoped, and it's completely encapsulated. It's just runs a query, sets some variables, and returns the results. What would happen if I were to reset the cache (by re-running cfset application.myCfc = new com.blah) while someone was using that cached call? There's enough traffic on the site that it's almost certian that there will be users on it when I reset the cache. This cached cfc is used on every page, so it's almost certain that someone will be in the middle of doing something with it when it's reset. What will happen for that user when this happens? Thanks, Eric Cobb http://www.cfgears.com ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346478 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Specifying Excel Data Types in CFCONTENT?
Thanks for the info, now that the project is not hold anymore, I will do this. I've used the POIUtility long ago, I'll check it out again. so I can't develop for 9 strictly yet. As an alternative, try the POIUtility.cfc. Like cfspreadsheet it generates a true Excel file. IIRC it should work on MX7 too. If you prefer to stick with pseudo-excel files (ie html) there are a lot of old css tricks floating around. Do a search on mso-number-format or just play around with a local Excel file. Format the cells as desired and save the workbook as html to view the generated css. http://stackoverflow. com/question s/354476/html-to-excel-how-can-tell-excel-to-treat-columns-as-numbers ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346479 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
cffunction - initialize query as empty string or QueryNew
Hello, We are discussing the proper way to initialize a query in a cffunction. Does it make a significant difference to use QueryNew rather than (empty string) as in the following: cfcomponent cffunction name=test access=public returntype=query output=false .this? cfset var myQuery = .or this? cfset var myQuery = QueryNew(col1,col2,VarChar,Time cfquery name=myQuery datasource=#myDB# ... /cfquery /cfcomponent I learned to use the first version var myQuery = from the CFMX Bible and the CF documentation but a colleague believes that this is a mistake and that using this approach creates the myQuery variable as a string and not as a query. Consequently, it is creating a variable of the wrong type. Any thoughts on this are welcome. Thanks, Jerry ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346480 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Label Printer
I have an inventory website and it would be nice to be able to print barcodes and product data to a label printer. Has anyone tried sending webpage content to a label printer? Or maybe there are some printers that can take XML content?? Looks like Zebra printers have their own printer language, but I dont see any way of using it with ColdFusion or any web browser content. http://www.zebra.com/id/zebra/na/en/index/products/software.html They also mention using XML with their printers, but I have not read up on how it works and the way it talks the printers that support this may be out of our price range. http://www.zebra.com/id/zebra/na/en/index/resource_library/getting_started/introduction_to_bar_code_printing/xml_enabled_printing.html If anyone has ideas or has done this let me know. Chad ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346481 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Label Printer
Dymo LabelWriter comes with ActiveX component and code sample that make it easy to do. -Original Message- From: Chad Gray cg...@careyweb.com Sent: Wednesday, August 03, 2011 11:50 AM To: cf-talk cf-talk@houseoffusion.com Subject: Label Printer I have an inventory website and it would be nice to be able to print barcodes and product data to a label printer. Has anyone tried sending webpage content to a label printer? Or maybe there are some printers that can take XML content?? Looks like Zebra printers have their own printer language, but I dont see any way of using it with ColdFusion or any web browser content. http://www.zebra.com/id/zebra/na/en/index/products/software.html They also mention using XML with their printers, but I have not read up on how it works and the way it talks the printers that support this may be out of our price range. http://www.zebra.com/id/zebra/na/en/index/resource_library/getting_started/introduction_to_bar_code_printing/xml_enabled_printing.html If anyone has ideas or has done this let me know. Chad ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346482 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: cffunction - initialize query as empty string or QueryNew
creates the myQuery variable as a string and not as a query. It does. But as soon as your run the cfquery the myQuery variable is essentially becomes a query object. Does it make a significant difference to use QueryNew rather than (empty string) as in the following: For a function that simple, I am not sure I see the benefit of declaring a query object that just gets replaced in the very next line. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346483 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Label Printer
Chad, I recommend you get a 3rd party printing application that is easy to integrate with. Seagull Scientific's BarTender works with Zebra printers, among many others, and integrates with web services, databases, COM automation, ActiveX controls, command-line calls, and probably more. That way it doesn't really matter what printer you use, as long as the software supports it and you can integrate with that. nathan strutz [www.dopefly.com] [hi.im/nathanstrutz] [about.me/nathanstrutz] On Wed, Aug 3, 2011 at 8:50 AM, Chad Gray cg...@careyweb.com wrote: I have an inventory website and it would be nice to be able to print barcodes and product data to a label printer. Has anyone tried sending webpage content to a label printer? Or maybe there are some printers that can take XML content?? Looks like Zebra printers have their own printer language, but I dont see any way of using it with ColdFusion or any web browser content. http://www.zebra.com/id/zebra/na/en/index/products/software.html They also mention using XML with their printers, but I have not read up on how it works and the way it talks the printers that support this may be out of our price range. http://www.zebra.com/id/zebra/na/en/index/resource_library/getting_started/introduction_to_bar_code_printing/xml_enabled_printing.html If anyone has ideas or has done this let me know. Chad ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346484 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Running systeminfo with CFEXECUTE returns an empty string. Why?
Any ideas what I'm doing wrong? Here's my code: cfexecute name=c:\windows\system32\systeminfo.exe arguments=/FO CSV variable=data timeout=10 / cfdump var=#data# I've also tried running it without the arguments (see below). Both the code above and the code below return an empty string: cfexecute name=c:\windows\system32\systeminfo.exe variable=data timeout=10 / cfdump var=#data# Any ideas? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346485 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
(ot) CFBuilder / Change format of default CFINVOKE tag
Sorry for the OT post, I haven't had any luck finding an answer to this one: When I use the services browser insert CFINVOKE option, it inserts it like this: -- cfinvoke component=application.logging.Log method=call cfinvokeargument name=SMS value= / cfinvokeargument name=email value= / cfinvokeargument name=throw value= / cfinvokeargument name=throwDetails value= //cfinvoke -- When what I want it to insert is like this: -- cfinvoke component=application.logging.log method=call sMS= email= throw= throwDetails= / -- Is there anyway to change the formatting of the tags? I know the first way might be better practice, but its also inconsistent with all my existing code. Brook ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346486 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: CF8 cfexecute Problem
That worked! Thank you so much! Is it because both the program Webshot and ColdFusion were installed under my user account? It's possible, but it's also possible that it was something not quite the same, but somewhat similar. I realize that's not a very satisfactory explanation, but I'd need to see more to be sure of the exact cause. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346487 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: cffunction - initialize query as empty string or QueryNew
It doesn't matter - CFML is not like Java (where you must pre-define variables with strict types). In CFML, variables can change types at any time. If you're just var scoping a cfquery variable, it doesn't matter what you use. (I would guess using QueryNew might be ever so slightly slower - but I doubt it's significant, and wouldn't be surprised if the JVM optimized it away anyhow.) You can avoid the pointless debate by using: cfquery name=local.myQuery etc If you're not on CF9/equivalent then you need a cfset var local = StructNew() / immediately after any arguments. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346488 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: Running systeminfo with CFEXECUTE returns an empty string. Why?
Logon to the CF server using the name of the user that CF was installed with and try running systeminfo.exe using a CMD prompt. My guess is that it is using a user that doesn't have permission to run that process, as I tried the second command you provided, and it worked just fine... -Original Message- From: Scott Niven [mailto:scott_ni...@ncsu.edu] Sent: Wednesday, August 03, 2011 11:39 AM To: cf-talk Subject: Running systeminfo with CFEXECUTE returns an empty string. Why? Any ideas what I'm doing wrong? Here's my code: cfexecute name=c:\windows\system32\systeminfo.exe arguments=/FO CSV variable=data timeout=10 / cfdump var=#data# I've also tried running it without the arguments (see below). Both the code above and the code below return an empty string: cfexecute name=c:\windows\system32\systeminfo.exe variable=data timeout=10 / cfdump var=#data# Any ideas? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346489 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: cffunction - initialize query as empty string or QueryNew
Leigh, Peter, Thanks for your comments. All makes sense to me. If I can ask one follow-up on Peter's answer though. I've recently started to work on CF9 and was using my cffunction techniques from the CF8 days. i.e., cfset var local = StructNew() cfset local.myVar1 = cfset local.myVar2 = ...and I'm trying to make sure I'm doing the right thing on CF9 by doing the following instead: cfset var myVar1 = cfset var myVar2 = cfif myVar EQ .. Is that correct CF9 approach to scoping vars within the CFC/cffunction? Jerry ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346490 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: cffunction - initialize query as empty string or QueryNew
With CF9 you don't need the var keyword anymore, and if you don't need backwards compatible code it's (arguably) clearer to not use it at all. That means, do NOT use either of your examples, unless you _need_ a value in myvar1/myvar2 at the start. Perhaps a good way to explain it is to use some sample functions... this is just a bit of nonsense code, but hopefully demonstrates the different ways to do it... cffunction name=test_cf8_var --- [imagine arguments here] --- cfset var myVar1 = / cfset var myVar2 = / cfif Arguments.Something EQ whatever cfset myVar1 = wibble / /cfif cfloop index=myVar2 from=0 to=10 cfset myVar1 = Variables.Data[myVar2] / /cfloop cfif len(myVar1) cfreturn myVar1 / cfelse cfreturn burp / /cfif /cffunction cffunction name=test_cf8_local --- [imagine arguments here] --- cfset var local = StructNew() / cfif Arguments.Something EQ whatever cfset local.myVar1 = wibble / cfelse cfset local.myVar1 = / /cfif cfloop index=local.myVar2 from=0 to=10 cfset local.myVar1 = Variables.Data[local.myVar2] / /cfloop cfif len(local.myVar1) cfreturn local.myVar1 / cfelse cfreturn burp / /cfif /cffunction cffunction name=test_cf9 --- [imagine arguments here] --- cfif Arguments.Something EQ whatever cfset local.myVar1 = wibble / cfelse cfset local.myVar1 = / /cfif cfloop index=local.myVar2 from=0 to=10 cfset local.myVar1 = Variables.Data[local.myVar2] / /cfloop cfif len(local.myVar1) cfreturn local.myVar1 / cfelse cfreturn burp / /cfif /cffunction ...does that make sense? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346491 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: cffunction - initialize query as empty string or QueryNew
With CF9 you don't need the var keyword anymore, and if you don't need backwards compatible code it's (arguably) clearer to not use it at all. That means, do NOT use either of your examples, unless you _need_ a value in myvar1/myvar2 at the start. Perhaps a good way to explain it is to use some sample functions... this is just a bit of nonsense code, but hopefully demonstrates the different ways to do it... cffunction name=test_cf8_var --- [imagine arguments here] --- cfset var myVar1 = / cfset var myVar2 = / cfif Arguments.Something EQ whatever cfset myVar1 = wibble / /cfif cfloop index=myVar2 from=0 to=10 cfset myVar1 = Variables.Data[myVar2] / /cfloop cfif len(myVar1) cfreturn myVar1 / cfelse cfreturn burp / /cfif /cffunction cffunction name=test_cf8_local --- [imagine arguments here] --- cfset var local = StructNew() / cfif Arguments.Something EQ whatever cfset local.myVar1 = wibble / cfelse cfset local.myVar1 = / /cfif cfloop index=local.myVar2 from=0 to=10 cfset local.myVar1 = Variables.Data[local.myVar2] / /cfloop cfif len(local.myVar1) cfreturn local.myVar1 / cfelse cfreturn burp / /cfif /cffunction cffunction name=test_cf9 --- [imagine arguments here] --- cfif Arguments.Something EQ whatever cfset local.myVar1 = wibble / cfelse cfset local.myVar1 = / /cfif cfloop index=local.myVar2 from=0 to=10 cfset local.myVar1 = Variables.Data[local.myVar2] / /cfloop cfif len(local.myVar1) cfreturn local.myVar1 / cfelse cfreturn burp / /cfif /cffunction ...does that make sense? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346492 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: cffunction - initialize query as empty string or QueryNew
Peter, great examples, really helpful. In a nutshell, if I get it, in CF9 you do not need to use: cfset var local = StructNew() / because you are going to define your vars as: local.myVar1 and local.myVar2 and the local structure is already defined by default. You refer to your vars throughout the cffunction as local.myVar. Hope that's right, Jerry ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346493 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
COMPLEX SQL RANDOM
I have this SQL statement below. cfquery name=random_poll datasource=#dsn# SELECT DISTINCT portal_polls.poll_id, portal_polls.question, portal_polls.answer1, portal_polls.answer2, portal_polls.answer2, portal_polls.answer4, portal_polls.answer4, portal_polls.number_answers FROM portal_polls, portal_groups_x_polls, portal_groups_x_students WHERE (portal_polls.start_date #Now()# and portal_polls.end_date #Now()#) and (everyone=1 OR (portal_groups_x_polls.poll_id=portal_polls.poll_id and portal_groups_x_students.group_id=portal_groups_x_polls.group_id and portal_groups_x_students.student_user_id=#session.userid#)) and not exists (SELECT * FROM portal_students_x_polls_completed WHERE portal_students_x_polls_completed.poll_id=portal_polls.poll_id and portal_students_x_polls_completed.student_user_id=#session.userid#); /cfquery In short it selects a list of polls which: 1. Are active (open but not ended) ... thus the start_date, end_date 2. Are open to everyone (everyone) OR open to a group for which this poll is allowed and in which the user (session.userid) is enrolled... thus the joins to portal_groups_x_polls and portal_groups_x_students) 3. and Have NOT already been completed by this user... thus the not exists in portal_students_x_polls_completed All this is working correctly, but I want to select ONLY 1 poll at RANDOM. Normally I would use TOP 1 and ORDER BY NEWID() to do this. But it doesn't like that with the DISTINCT clase. I'm using DISTINCT because the same poll could come up several times if it's allowed in multiple groups and that use is in several of those groups. And I would drop the DISTINCT but if one poll comes up a bunch of times that would increase the likelihood it would be selected at random. Anyone know how I can adjust this query to select only 1 matching record at random? Thanks, Robert Robert B. Harrison Director of Interactive Services Austin Williams 125 Kennedy Drive, Suite 100 Hauppauge NY 11788 P : 631.231.6600 Ext. 119 F : 631.434.7022 http://www.austin-williams.com Great advertising can't be either/or. It must be . Plug in to our blog: AW Unplugged http://www.austin-williams.com/unplugge ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346494 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: COMPLEX SQL RANDOM
What I'm trying to do should look like this: cfquery name=random_poll datasource=#dsn# SELECT DISTINCT TOP 1 portal_polls.poll_id, portal_polls.question, portal_polls.answer1, portal_polls.answer2, portal_polls.answer2, portal_polls.answer4, portal_polls.answer4, portal_polls.number_answers FROM portal_polls, portal_groups_x_polls, portal_groups_x_students WHERE (portal_polls.start_date #Now()# and portal_polls.end_date #Now()#) and (everyone=1 OR (portal_groups_x_polls.poll_id=portal_polls.poll_id and portal_groups_x_students.group_id=portal_groups_x_polls.group_id and portal_groups_x_students.student_user_id=#session.userid#)) and not exists (SELECT * FROM portal_students_x_polls_completed WHERE portal_students_x_polls_completed.poll_id=portal_polls.poll_id and portal_students_x_polls_completed.student_user_id=#session.userid#) ORDER BY NEWID() /cfquery But when I do that it tells me: ORDER BY items must appear in the select list if SELECT DISTINCT is specified. I'm selecting distinct because of the likelihood that some records may be weighted if in multiple groups... and I don't want that to be a factor. Ideas? Thanks Robert B. Harrison Director of Interactive Services Austin Williams 125 Kennedy Drive, Suite 100 Hauppauge NY 11788 P : 631.231.6600 Ext. 119 F : 631.434.7022 http://www.austin-williams.com Great advertising can't be either/or. It must be . Plug in to our blog: AW Unplugged http://www.austin-williams.com/unplugged ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346495 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: COMPLEX SQL RANDOM
Since the query you have gives you the list of polls that you want, what about dumping the results of that query into a temp table, and doing a random select on the temp table with SELECT TOP 1 and ORDER BY NEWID() ? Steve On Wed, Aug 3, 2011 at 2:43 PM, Robert Harrison rob...@austin-williams.comwrote: I have this SQL statement below. cfquery name=random_poll datasource=#dsn# SELECT DISTINCT portal_polls.poll_id, portal_polls.question, portal_polls.answer1, portal_polls.answer2, portal_polls.answer2, portal_polls.answer4, portal_polls.answer4, portal_polls.number_answers FROM portal_polls, portal_groups_x_polls, portal_groups_x_students WHERE (portal_polls.start_date #Now()# and portal_polls.end_date #Now()#) and (everyone=1 OR (portal_groups_x_polls.poll_id=portal_polls.poll_id and portal_groups_x_students.group_id=portal_groups_x_polls.group_id and portal_groups_x_students.student_user_id=#session.userid#)) and not exists (SELECT * FROM portal_students_x_polls_completed WHERE portal_students_x_polls_completed.poll_id=portal_polls.poll_id and portal_students_x_polls_completed.student_user_id=#session.userid#); /cfquery In short it selects a list of polls which: 1. Are active (open but not ended) ... thus the start_date, end_date 2. Are open to everyone (everyone) OR open to a group for which this poll is allowed and in which the user (session.userid) is enrolled... thus the joins to portal_groups_x_polls and portal_groups_x_students) 3. and Have NOT already been completed by this user... thus the not exists in portal_students_x_polls_completed All this is working correctly, but I want to select ONLY 1 poll at RANDOM. Normally I would use TOP 1 and ORDER BY NEWID() to do this. But it doesn't like that with the DISTINCT clase. I'm using DISTINCT because the same poll could come up several times if it's allowed in multiple groups and that use is in several of those groups. And I would drop the DISTINCT but if one poll comes up a bunch of times that would increase the likelihood it would be selected at random. Anyone know how I can adjust this query to select only 1 matching record at random? Thanks, Robert Robert B. Harrison Director of Interactive Services Austin Williams 125 Kennedy Drive, Suite 100 Hauppauge NY 11788 P : 631.231.6600 Ext. 119 F : 631.434.7022 http://www.austin-williams.com Great advertising can't be either/or. It must be . Plug in to our blog: AW Unplugged http://www.austin-williams.com/unplugge ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346496 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: COMPLEX SQL RANDOM
Since the query you have gives you the list of polls that you want, what about dumping the results of that query into a temp table, and doing a random select on the temp table with SELECT TOP 1 and ORDER BY NEWID() ? I have considered that, but this should be possible in one straight up SQL statement. It's annoying me and I'm being anal... but I want it right. Robert B. Harrison Director of Interactive Services Austin Williams 125 Kennedy Drive, Suite 100 Hauppauge NY 11788 P : 631.231.6600 Ext. 119 F : 631.434.7022 http://www.austin-williams.com Great advertising can't be either/or. It must be . Plug in to our blog: AW Unplugged http://www.austin-williams.com/unplugged ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346497 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: COMPLEX SQL RANDOM
But when I do that it tells me: ORDER BY items must appear in the select list if SELECT DISTINCT is specified. I cannot speak for the query itself, but using a derived table comes to mind as a possibility. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346498 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: COMPLEX SQL RANDOM
The error message you are getting is because the value of your order by clause, newID(), is not a part of your list of values you are selecting. You could, of course, include it in your list of values by first setting it to a variable, like so: declare @orderClause as uniqueidentifier; set @orderClause = NEWID(); select distinct top 1 fieldA, fieldB, @orderClause as fieldC from table order by fieldC This would get you past the error you are receiving about the ORDER BY clause must appear in the select list. However, because every row in your resulting recordset now has a field called fieldC with the value of your previously generated ID, you will lost your randomness as the first row will always be returned. Experiment on a simpler table than what you are working with using the above code as a guide and you'll see what I mean. I'm not sure you can do this in 1 step. I would still recommend the temporary table (rather, the derived table as pointed out by Leigh). Steve On Wed, Aug 3, 2011 at 2:54 PM, Robert Harrison rob...@austin-williams.comwrote: Since the query you have gives you the list of polls that you want, what about dumping the results of that query into a temp table, and doing a random select on the temp table with SELECT TOP 1 and ORDER BY NEWID() ? I have considered that, but this should be possible in one straight up SQL statement. It's annoying me and I'm being anal... but I want it right. Robert B. Harrison Director of Interactive Services Austin Williams 125 Kennedy Drive, Suite 100 Hauppauge NY 11788 P : 631.231.6600 Ext. 119 F : 631.434.7022 http://www.austin-williams.com Great advertising can't be either/or. It must be . Plug in to our blog: AW Unplugged http://www.austin-williams.com/unplugged ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346499 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
RE: COMPLEX SQL RANDOM
Why not try something like this...(not sure which database you are using) SELECT TOP 1 * FROM ( SELECT DISTINCT portal_polls.poll_id, portal_polls.question, portal_polls.answer1, portal_polls.answer2, portal_polls.answer2, portal_polls.answer4, portal_polls.answer4, portal_polls.number_answers FROM portal_polls, portal_groups_x_polls, portal_groups_x_students WHERE (portal_polls.start_date #Now()# and portal_polls.end_date #Now()#) and (everyone=1 OR (portal_groups_x_polls.poll_id=portal_polls.poll_id and portal_groups_x_students.group_id=portal_groups_x_polls.group_id and portal_groups_x_students.student_user_id=#session.userid#)) and not exists (SELECT * FROM portal_students_x_polls_completed WHERE portal_students_x_polls_completed.poll_id=portal_polls.poll_id and portal_students_x_polls_completed.student_user_id=#session.userid#); ) -Original Message- From: Steve Milburn [mailto:scmilb...@gmail.com] Sent: Wednesday, August 03, 2011 2:33 PM To: cf-talk Subject: Re: COMPLEX SQL RANDOM The error message you are getting is because the value of your order by clause, newID(), is not a part of your list of values you are selecting. You could, of course, include it in your list of values by first setting it to a variable, like so: declare @orderClause as uniqueidentifier; set @orderClause = NEWID(); select distinct top 1 fieldA, fieldB, @orderClause as fieldC from table order by fieldC This would get you past the error you are receiving about the ORDER BY clause must appear in the select list. However, because every row in your resulting recordset now has a field called fieldC with the value of your previously generated ID, you will lost your randomness as the first row will always be returned. Experiment on a simpler table than what you are working with using the above code as a guide and you'll see what I mean. I'm not sure you can do this in 1 step. I would still recommend the temporary table (rather, the derived table as pointed out by Leigh). Steve On Wed, Aug 3, 2011 at 2:54 PM, Robert Harrison rob...@austin-williams.comwrote: Since the query you have gives you the list of polls that you want, what about dumping the results of that query into a temp table, and doing a random select on the temp table with SELECT TOP 1 and ORDER BY NEWID() ? I have considered that, but this should be possible in one straight up SQL statement. It's annoying me and I'm being anal... but I want it right. Robert B. Harrison Director of Interactive Services Austin Williams 125 Kennedy Drive, Suite 100 Hauppauge NY 11788 P : 631.231.6600 Ext. 119 F : 631.434.7022 http://www.austin-williams.com Great advertising can't be either/or. It must be . Plug in to our blog: AW Unplugged http://www.austin-williams.com/unplugged ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346500 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: COMPLEX SQL RANDOM
On Wed, Aug 3, 2011 at 8:43 PM, Robert Harrison wrote: Normally I would use TOP 1 and ORDER BY NEWID() to do this. But it doesn't like that with the DISTINCT clase. I'm using DISTINCT because the same poll could come up several times if it's allowed in multiple groups and that use is in several of those groups. And I would drop the DISTINCT but if one poll comes up a bunch of times that would increase the likelihood it would be selected at random. The reason for this skew is the order of execution: first you calculate matches (resulting in multiple rows for some polls), then you assign each a newID(). The solution is to assign the newID() first (when each poll only occurs once) and then calculate the matches. One of the most readable ways to force an execution order is with a CTE, which should look something like: -- define a CTE open_polls WITH open_polls AS ( SELECT portal_polls.* , NewID() as randomNumber FROM portal_polls WHERE -- with polls that are currently open portal_polls.start_date #Now()# and portal_polls.end_date #Now()# -- and have not been completed by this user and not exists ( SELECT * FROM portal_students_x_polls_completed WHERE portal_students_x_polls_completed.poll_id=portal_polls.poll_id and portal_students_x_polls_completed.student_user_id=#session.userid# ) ) -- from which we select one row SELECT TOP 1 open_polls.poll_id, open_polls.question, open_polls.answer1, open_polls.answer2, open_polls.answer2, open_polls.answer4, open_polls.answer4, open_polls.number_answers FROM open_polls, portal_groups_x_polls, portal_groups_x_students WHERE (everyone=1 OR ( portal_groups_x_polls.poll_id=open_polls.poll_id and portal_groups_x_students.group_id=portal_groups_x_polls.group_id and portal_groups_x_students.student_user_id=#session.userid# ) ) ORDER BY open_polls.randomNumber; Jochem -- Jochem van Dieten http://jochem.vandieten.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346501 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: COMPLEX SQL RANDOM
because every row in your resulting recordset now has a field called fieldC with the value of your previously generated ID That is because a variable is used rather of calling the function directly within the SELECT list. The latter (usually) forces the function to be evaluated once per row. There are some exceptions, so check the ms sql docs for the expected behavior. ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346502 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: COMPLEX SQL RANDOM
On Wed, Aug 3, 2011 at 9:36 PM, Bill Franklin wrote: Why not try something like this...(not sure which database you are using) SELECT TOP 1 * FROM ( SELECT DISTINCT portal_polls.poll_id, portal_polls.question, portal_polls.answer1, portal_polls.answer2, portal_polls.answer2, portal_polls.answer4, portal_polls.answer4, portal_polls.number_answers FROM portal_polls, portal_groups_x_polls, portal_groups_x_students WHERE (portal_polls.start_date #Now()# and portal_polls.end_date #Now()#) and (everyone=1 OR (portal_groups_x_polls.poll_id=portal_polls.poll_id and portal_groups_x_students.group_id=portal_groups_x_polls.group_id and portal_groups_x_students.student_user_id=#session.userid#)) and not exists (SELECT * FROM portal_students_x_polls_completed WHERE portal_students_x_polls_completed.poll_id=portal_polls.poll_id and portal_students_x_polls_completed.student_user_id=#session.userid#); ) Because this query does not have a random result. The result of the outer query will always be the first row of the inner query. The result of the inner query will be in a predictable order based on the indexes and statistics (probably whichever row is returned first by the index over poll_id, start_date and end_date as I suspect that will be the driving index). Jochem -- Jochem van Dieten http://jochem.vandieten.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346503 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: COMPLEX SQL RANDOM
Offhand do you know if there are any issues using NEWID() within CTE's? I have a vague recollection of issues with that function. Either when used within CTE's or possible derived tables. Not sure. -Leigh ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346504 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Resetting cached components
On Wed, Aug 3, 2011 at 4:41 PM, Eric Cobb wrote: Let's say I've got an object cached in the application scope. The call to this CFC is used throughout the site, which gets a lot of traffic. Everything inside the CFC is var scoped, and it's completely encapsulated. It's just runs a query, sets some variables, and returns the results. What would happen if I were to reset the cache (by re-running cfset application.myCfc = new com.blah) while someone was using that cached call? The short answer: requests would use either the old instance or the new instance, so the only way you would get a problem is if the requests call multiple methods on the CFC (or one method multiple times) and expect the results to be consistent between calls. (If your application expects that consistency, put the cfc instance in the request scope in the onRequestStart() and use that throughout your application. The long answer is a bit more complicated and depends on your exact addressing scheme. Imagine the following (pseudo)code in some template: 1. cfset application.myCfc = new utilCfc() / 2. cfset local.something[1].localReference = application.myCfc / 3. cfset application.myCfc = new utilCfc() / 4. cfset local.something[1].localReference.doSomething() / 5. cfset application.myCfc.doSomething() / If you use patterns like this the code in line 4 and 5 may refer to different instances of utilCfc because in line 4 you are addressing utilCfc through an intermediate variable that may or may not have been updated by the code on line 3, while in line 5 you are definitely talking to the new instance that was created by line 3. Consistent coding is not just for readability :) Jochem -- Jochem van Dieten http://jochem.vandieten.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346505 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: COMPLEX SQL RANDOM
On Wed, Aug 3, 2011 at 10:13 PM, Leigh wrote: Offhand do you know if there are any issues using NEWID() within CTE's? I have a vague recollection of issues with that function. Either when used within CTE's or possible derived tables. Not sure. Not that I am aware off. But then again, I didn't even know that uniqueidentifiers had a comparator nowadays and could be sorted :) Jochem -- Jochem van Dieten http://jochem.vandieten.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346506 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: COMPLEX SQL RANDOM
Not that I am aware off. But then again, I didn't even know that uniqueidentifiers had a comparator nowadays and could be sorted :) Yeah, it is hard to keep up with all the changes. Anyway, I may have a around later. If I actually manage to find a reference, I will post back ;) -Leigh ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346507 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: Label Printer
On Wed, Aug 3, 2011 at 5:50 PM, Chad Gray wrote: I have an inventory website and it would be nice to be able to print barcodes and product data to a label printer. Do you want to print to your own printer or should the visitor print to his printer? In the latter case it may be a better idea to provide a PDF generation service that generates PDFs with a paper size suitable for labels so they can be printed on general purpose printers as well. (Or if you have a label printer yourself you should see if it is supported by cfprint.) Jochem -- Jochem van Dieten http://jochem.vandieten.net/ ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346508 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: ODBC (microsoft access) DSN's not working
Russ, Did you ever figure out what was going on because I am having the exact same issue. David Moore ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346509 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Mac 10.7 datasource problem
Since I upgraded to lion, my sql server datasource has stopped working. The error message i'm getting is: java.sql.SQLNonTransientConnectionException: [Macromedia][SQLServer JDBC Driver]No more data available to read. Anyone know anything about this? ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346510 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm
Re: ODBC (microsoft access) DSN's not working
yes I did, here are the details. http://www.michaels.me.uk/post.cfm/msaccess-dsn-s-no-longer-work-after-cf-9-0-1-upgrade On Wed, Aug 3, 2011 at 11:56 PM, David Moore dgmoor...@hotmail.com wrote: Russ, Did you ever figure out what was going on because I am having the exact same issue. David Moore ~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:346511 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm