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,238 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 20, 2013 at 4:38 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Dana, Your confusion is well founded, since this is a very confusing features. In fact, it ONLY works if you use array notation. Meaning, that this: arrayToList( query[ "columnName" ] ) ... read »
May 20, 2013 at 4:34 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
I was thinking chicken and the egg, I wouldn't have expected it to work in the valuelist going in I guess. Maybe I just need a beer, long day :) ... read »
May 20, 2013 at 4:29 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Dana, That's if you're trying to reference a specific row. In this case, we're trying to reference the entire query column as one cohesive value. So, you are correct that if you wanted to output a ... read »
May 20, 2013 at 4:24 PM
Using A Dynamic Column Name With ValueList() In ColdFusion
I thought when you used array notation to reference queries you always had to have the row or it would throw a similar error as well? ... read »
May 20, 2013 at 11:45 AM
Using jQuery's Animate() Step Callback Function To Create Custom Animations
This is really useful. I found out that you don't actually have to use a dummy css property (surprisingly). To animate a property in a linear-gradient for instance I did this this.css('someLinearGra ... read »
May 20, 2013 at 10:51 AM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Josh, Oh snap! You're totally right! I'm not sure I've ever tried that. I did know that you can call a number of other array-methods on ColdFusion query columns: http://www.bennadel.com/blog/167 ... read »
May 20, 2013 at 10:45 AM
Using A Dynamic Column Name With ValueList() In ColdFusion
@Ben - I believe you can achieve the same functionality with ColdFusion's built in ArrayToList() function. ArrayToList( users[ "id" ] ); ... read »
May 20, 2013 at 10:21 AM
My Experience With AngularJS - The Super-heroic JavaScript MVW Framework
Is there any error logging and handling framework in angularjs, if not then in what way I can do this. ... read »
InVision App - Prototyping Made Beautiful With Prototyping Tools