Query of Queries Trims Whitespace Automatically

After literally hours of tracking down what was causing a large code base to behave badly, I found an odd and frustrating features when doing a query of queries with <cfquery>. Take the following code as an example of what you would think works:


<cfquery name="q1" datasource="#application.DSN#">
    SELECT ' A2010 ' as v1
    FROM Seasons
    WHERE teamid = <cfqueryparam value="18513" cfsqltype="cf_sql_integer">
</cfquery>

<cfquery name="q2" dbtype="query">
    SELECT v1
    FROM q1
    WHERE LOWER(v1) = '#Lcase(' A2010 ')#'
</cfquery>

The above code will return 10 results for q1 but none for q2 even though they are both matching " 2010 ".

To fix the issue I tried using in the second query and even tried replacing the space with a #chr(32)# character code. Neither worked.

Changing the query to the following works:


<cfquery name="q1" datasource="#application.DSN#">
    SELECT ' A2010 ' as v1
    FROM Seasons
    WHERE teamid = <cfqueryparam value="18513" cfsqltype="cf_sql_integer">
</cfquery>

<cfquery name="q2" dbtype="query">
    SELECT v1
    FROM q1
    WHERE LOWER(v1) = '#Lcase('A2010')#'
</cfquery>

Notice I removed the space before and after the 2010 in the second query. This will return all 10 results even though it is not an exact match.

ColdFusion is automatically trimming the whitespace of the values returned from q1.

The only solution I can find is to trim the value to match as well. This will provide for an inexact match, but will work for my purpose. This is very concerning because you could have a lack of results and not even know it without inspecting it.

The final code I've come up with for a "sorta-fix-workaround" is:


<cfquery name="q1" datasource="#application.DSN#">
    SELECT ' A2010 ' as v1
    FROM Seasons
    WHERE teamid = <cfqueryparam value="18513" cfsqltype="cf_sql_integer">
</cfquery>

<cfquery name="q2" dbtype="query">
    SELECT v1
    FROM q1
    WHERE LOWER(v1) = '#Lcase(Trim(' A2010 '))#'
</cfquery>

Your Website - On YouTube?

At the risk of sounding outdated to some -- I have found a brilliant way of combining a website and social media advertising. What if you could take your website - and squish it into YouTube? (betting you're saying "huh?").

BooneOakley has found a way. They where recently featured in the Adobe Edge Newsletter and have seen more than 400,000 view in a matter of weeks.

So how do they squish a website into YouTube medium? It starts out with a video clip that takes advantage of YouTube's framework. This allows viewers to click links inside the video, just like a webpage. You are then taken to corresponding video, which tells you about what you just clicked on, or allows for deeper navigation.

What will people think of next? Check them out at http://www.booneoakley.com/

Project Natal - Milo

As a total "geek", many people assume that I sit at home after work and play X-Box or Playstation all night. But the truth is, those game consoles are just to complicated for my taste. In fact, rarely do I play video games.

What I do enjoy in the arena however, is my Nintendo Wii. I enjoy the simple, yet interactive and challenging games such as the Wii Fit, Disney Trivia, Tetris, Wii Sports, Mario and others. However - I do wish the graphics where a little more modernized and the AI pieces just quite aren't there.

[More]

Wireless Printers

I went on a new printer mission a couple of weeks ago for my home. I had an Epson printer for a few years, but lost my power cord after my move (which of course I found after I bought this new printer).

I have a laptop that I like to use on my lap while watching TV in the living room. But if I ever wanted to print something I'd always have to plug in the USB port to the printer in the next room. Wouldn't it be great if I had a network printer? But those costs hundereds if not thousands of dollars - right?

So went to my local electronics store a low-and-behold a wireless printer! (Well, they haven't made wireless power yet without cooking yourself to death) And what's more, it's sub-$100!

I picked up a Brother MFC-490CW Multifunction printer. I had my reservations thinking wireless might be slow and not reliable. However I found just the opposite. It was easy to setup and a breeze to print, scan, copy, etc. Plus there's no wires! Looking at the ink prices, they're pretty cheap too - (yea eBay!).

I highly recommend this product to anyone looking to free themselves yet not do away with any of the advantages of this type of system.

Got a Shovel? Score $3,500 worth of Adobe CS4 Master Collection!

Get yourself a shovel, a plane, a parachute, survival kit, and some mace.

Drop at coordinates N 37deg 31.357' W 122deg 19.085', elevation 603ft.

There underneath the ground you will find CS4 Master Collection, wrapped in plastic and duct tape.

Survellince video posted at http://theflashblog.com/?p=712.

This message will self destruct when you take a hammer to your screen.

Backing Up Your Computer

I was recently engaged in a short discussion regarding Amazon's S3 Storage Service. This reminded me of a great backup solution I use for my personal computer.

Most people do not backup their computer for a number of reasons; too complicated, too cumbersome, too costly, "I need to backup?". But fate comes to play, and poof! there it goes. All those family photos, legal documents, music, etc.

Here's a cheap, easy way to backup your computer. Download, install, signup, and forget. Introducing Jungle Disk (and no I'm not getting paid to promote this). It cost me $20.00 upfront with lifetime free upgrades and 15 cents per GB-Month of storage used, plus a little for data transfer. All-in-all I'm getting charged about $3.50 to backup all my photos, some videos, personal website projects, documents, and more.

The software Jungle Disk uses Amazon's S3 Storage Service to store my data, keep it encrypted, automate the backup, and make available on Amazon.com's datacenters for high availability.

So unless your bank account is at zero, there's no reason not to backup your computer anymore. What's more is you can actually use it like a network drive if you want and you only pay for what you use.

BlogCFC was created by Raymond Camden. This blog is running version 5.9.1. Contact Blog Owner