ColdFusion SQL Error - [Table ....] Is Not Indexable By Name

Posted June 12, 2006 at 6:21 PM by Ben Nadel

Tags: ColdFusion, SQL

I was helping a co-worker of mine tracking down a ColdFusion error he was getting:

  • [Table (rows 1 columns ID, PREFIX, FIRST_NAME, MIDDLE_NAME, LAST_NAME, SUFFIX, WORKING_NAME): [ID: coldfusion.sql.QueryColumn@c4736a] [PREFIX:
  • coldfusion.sql.QueryColumn@17542e7] [FIRST_NAME:
  • coldfusion.sql.QueryColumn@17b5ee7] [MIDDLE_NAME:
  • coldfusion.sql.QueryColumn@93ab1f] [LAST_NAME:
  • coldfusion.sql.QueryColumn@c79c37] [SUFFIX:
  • coldfusion.sql.QueryColumn@e0eb96] [WORKING_NAME:
  • coldfusion.sql.QueryColumn@8af270] ] is not indexable by name

I hadn't seen this error before, so the phrase "indexable" immediately made me think about full text indexes and primary keys. After several minutes of moving CFTRY/CFCATCH tags around, we finally found a better error message. It said something like the SELECT column 'name' was not a reference in any of the FROM tables. It was suddenly obvious; in his Query of Queries, the 'name' column was not defined. I find it very funny when simple mistakes take a lot of debugging.

On another note though, I think it is very interesting that the error thrown by the Query of Queries CFQuery tag was different than the one available in CFCATCH. Well, maybe not different at the core, but worded very differently.



Reader Comments

Nov 21, 2006 at 9:30 AM // reply »
1 Comments

I go this error this morning, however I got it when I tried inserting a structure to a row of a query as in:

<cfset Tmp = StructInsert(QueryName[CurrentRow],OtherQueryName,QueryValue,true)>

I was pretty much trying my luck, half-expected the error. I hope this helps.

I'm working on work-around - thanks!


Jun 24, 2008 at 5:31 PM // reply »
1 Comments

I recently was faced with the same problem, but for a different reason: I was trying to implement POIUtility into my application and in the ColumnList I left spaces after each comma. Removing the spaces fixed the problem.


Sep 4, 2009 at 7:11 PM // reply »
1 Comments

@Kamil - thanks for the tip - I just ran into that.


Jul 12, 2010 at 1:19 PM // reply »
158 Comments

@kamil,

You're a brain-saver. Wow. I */knew/* my column existed as it was being CFDumped in the code immediately preceeding.

For people of the future... I had
listtoarray("col1, <SPACE> col2, <SPACE> Col3")

the fix:
LtA("col1,col2,col3")

Thus, the HTMLEditFormat(Query[Columns[ColID]][Query.CurrentRow]) was being fed the array w/o spaces


Jul 14, 2010 at 2:23 PM // reply »
1 Comments

You think it's funny....I think it's a pain. Thanks for the documentation though.
-A


Nov 11, 2010 at 9:43 PM // reply »
18 Comments

Thought I would add to this...

I thought it was because I did not define the column in my query. I was wrong. I was outputting my query in CFScript using a for loop.

if(bldg_resultset.recordCount gt 0){
for(i=1;i<=bldg_resultset.recordCount;i++)
//ArrayAppend(bldgArray,bldg_resultset[i].bldgid); ArrayAppend(bldgArray,bldg_resultset.bldgid[i]);
}

The commented out code gave me this exact error, but instead of name it was '1', the value of the first i.


Nov 17, 2010 at 10:27 AM // reply »
11,243 Comments

@Brad,

Good point - the column name always has to come first... which is definitely counter-intuitive if you think of queries as "arrays" of "structs".


Feb 16, 2012 at 1:43 PM // reply »
1 Comments

I bounced into the same problem and it was even simpler but yet was a stumper. I had the columns listed correctly or so I thought. Only thing in my quest to have properly formatted code, I had spaces between each column. Don't ask! Thing was when it was it included the space in the error message but since i wasn't looking for it I didn't see them. Thanks for the tip!

Iain


Mar 22, 2012 at 4:12 PM // reply »
1 Comments

I had this same issue as well but from a different approach. I didn't have a misspelled name and the column was defined. In fact, I wasn't even really using that particular column in my query, although I was doing SELECT * to get the whole row.

I basically had a function that took an ID and a recordset as arguments. From a QoQ the recordset gets narrowed down, but it is highly likely that I will get back multiple rows still with the same ID.

Through a bunch of calculations and whatnot, I single out the one row I am interested in, save that row number to a variable, and attempt to return that row to the calling page, and this is where that same error came from.

You cannot return a row from a recordset like:
<cfreturn queryname[row_index]>

The trick around this is to create another column in your table and have an incremental counter in it. instead of saving 'CurrentRow' to the row_index variable (to store the current index) and returning queryname[row_index], you do another QoQ to find the row that contains the value row_index in your new column.

Then, you can return this entire query and you now have your singled out row...no more errors :)


May 2, 2012 at 10:34 AM // reply »
3 Comments

I encountered the same error, "..coldfusion is not indexable by LEFT(column name)..." in a regular query. Maybe this goes without saying to some but my original code:

SELECT art_key,left(art_title,50)
FROM cts_article

just needed a small tweak:

SELECT art_key,left(art_title,50) AS art_title
FROM cts_article

which I tried because this post mention how the query of queries had not defined the 'name' column.

[just posting in case others find their way here from a search on the same error]


Mar 1, 2013 at 9:26 AM // reply »
1 Comments

Yeah Derek Versteegen!!! your post solve my problem: giving an alias to the column


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
May 23, 2013 at 5:19 AM
Ask Ben: Print Part Of A Web Page With jQuery
How to print also the background color of table cells and table lines ... read »
May 23, 2013 at 3:55 AM
Javascript Array Methods: Unshift(), Shift(), Push(), And Pop()
very interesting and helpful too. ... read »
May 22, 2013 at 5:35 PM
Script Tags, jQuery, And Html(), Text() And Contents()
This is still an issue 2 years later. jQuery is supposed to remediate these cross browser issues, no? I have been unable to find any statement from the jQuery team calling this behavior "by de ... read »
May 22, 2013 at 12:44 PM
Ask Ben: Query Loop Inside CFScript Tags
In cf10, if you call a function that has: local.result = {}; local.result.msg = ""; local.svc = new query(); local.svc.setSQL("SELECT * FROM..."); local.obj = local.svc.exe ... read »
May 22, 2013 at 12:29 PM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Ben: What version of Java are you using? Also, did you test users.id to see what Java reports as the data type? I wonder if it's not a Java primitive data type, but getting returned as something ... read »
May 22, 2013 at 11:47 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Dana, Awesome - so it looks like this bug was fixed in ColdFusion 10. Thanks so much for double-checking that. ... read »
May 22, 2013 at 11:37 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
When I c&p and run on cf10, I get: Selected User IDs: 1,4 User 1 selected: YES - YES User 2 selected: NO - NO User 3 selected: NO - NO User 4 selected: YES - YES User 5 selected: NO - ... read »
May 22, 2013 at 11:27 AM
Strange Interaction Between DeserializeJson(), ArrayContains(), And Database Values In ColdFusion
@Tom, Good thought, but no dice. Both of these still exhibit the same behavior: users.id[ users.currentRow ] users[ "id" ][ users.currentRow ] It's just something whacky happening with ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools