Questions tagged [cfquery]

`` is the primary method of executing database queries and query-of-queries (QoQ) in ColdFusion/CFML.

<cfquery> is the primary method of executing database queries and query-of-queries (QoQ) in ColdFusion/CFML. The <cfquery> tag's more common attributes include:

  • name - The name by which the query will be referred in code.
  • datasource - The data source against which the query is to be executed. Conflicts with dbtype.
  • dbtype - Used with a value of query for query-of-queries (QoQ) and with a value of hql for ORM. Conflicts with datasource.
  • cachedwithin - The time span for which the query results should be cached. Note: ColdFusion caches queries according to the name and text of the query; if either changes, the query will not be cached.
  • maxrows - The maximum number of rows to be returned from the query. Use -1 to return all rows. Note: This does not affect caching (see cachedwithin above); if maxrows is changed on a cached query, the query will still return the number of rows returned when it was first cached.
  • timeout - The number of seconds ColdFusion should wait before timing out the query. If <cfsetting requesttimeout="*xxx*" /> is used, will override that value if the timeout specified for the query is used.

Also see:

(Please see the tag's documentation for additional attributes and their explanation.)

246 questions
37
votes
8 answers

Can I get a query row by index in ColdFusion?

I want to get a specific row in a ColdFusion Query object without looping over it. I'd like to do something like this: SELECT * FROM tablename But it's giving me an…
Brian Bolton
  • 3,633
  • 8
  • 35
  • 43
22
votes
3 answers

How to convert Query column to a list in ColdFusion

I'm trying to convert ColdFusion query column to a list, what is the best way to do so? I thought that there is a built in function that allows one to easily convert a query's column in to a list, if there is what is it?
erikvold
  • 15,988
  • 11
  • 54
  • 98
8
votes
2 answers

Why won't this query cache in ColdFusion 9.01 using cfscript?

I am writing a query in ColdFusion 9.01 script and having trouble understanding why it is not caching the results. The same exact query will cache when executed using the CFML tag syntax. The SQL, datasource, username, password are not changing. I…
Aaron Greenlee
  • 4,587
  • 4
  • 26
  • 37
8
votes
2 answers

How can I stop Coldfusion from converting query column names to upper case?

When I select data from a MySQL table using the cfquery tag in ColdFusion 8, the column names are all converted to uppercase even though I've stored them in camelCase in the database table. Is there a way to make ColdFusion respect the case of the…
Jens Wegar
  • 4,147
  • 4
  • 29
  • 34
8
votes
1 answer

cfquery crashes when there are tsql comments

This does not crash in ColdFusion 11, but does crash in ColdFusion 2016 SELECT * FROM dbo.Roles WITH (NOLOCK) WHERE Code IS NOT NULL AND Active = 1 AND RoleID IN (SELECT RoleID FROM dbo.Emp WITH (NOLOCK)) -- It's ok to look at termed…
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
7
votes
5 answers

How do you use cfqueryparam in the ORDER BY clause?

I'm trying to be a good CF web developer and use around all FORM or URL elements that make it to my SQL queries. In this case, I'm trying to allow a user to control the ORDER BY clause dynamically.
Chris Brandt
  • 948
  • 3
  • 11
  • 22
7
votes
1 answer

Is there any limitation with number queries/statements we can write inside cftransaction?

Today while fixing bugs in some existing code I found a strange error. Branch target offset too large for short After searching I found that it is something to do with Java byte code conversion. Here are the links I found: Branch target offset…
Deepak Kumar Padhy
  • 4,128
  • 6
  • 43
  • 79
7
votes
2 answers

Is there any logical reason to use CFQUERYPARAM in Query of Queries?

I primarily use CFQUERYPARAM to prevent SQL injection. Since Query-of-Queries (QoQ) does not touch the database, is there any logical reason to use CFQUERYPARAM in them? I know that values that do not match the cfsqltype and maxlength will throw an…
Eric Belair
  • 10,574
  • 13
  • 75
  • 116
6
votes
1 answer

How can one get a list of all queries that have run on a page in ColdFusion 9

I would like to add some code to my Application.cfc onRequestEnd function that, if a certain application variable flag is on, will log query sql and execution time to a database table. That part is relatively easy, since ColdFusion returns the sql…
6
votes
3 answers

Using cfqueryparam with a ColdFusion HQL query

I am using a HQL query to get a bunch of state objects like so: from States where countryID = #ARGUMENTS.countryID# order by name asc This works fine. However, I was brought up well and…
Ciaran Archer
  • 12,316
  • 9
  • 38
  • 55
6
votes
2 answers

Get Primary Key after using CFINSERT - ColdFusion

When I use CFINSERT the form data is inserted into my database because the field names match the column names. MY QUESTION: How can I get the primary key of the row I just added using the CFINSERT? I know I cant use "Result='variable'" similar to…
Denoteone
  • 4,043
  • 21
  • 96
  • 150
6
votes
2 answers

ColdFusion inital value of currentrow when no index specified in cfloop

I am converting a ColdFusion application to C# (I'm a CF n00b). I have a script that performs a cfquery and then cfloop's through the results, and it appears to be trying to compare the current row to its following row. And it appears to be trying…
Rick Hodder
  • 2,189
  • 3
  • 26
  • 54
5
votes
3 answers

How to override SQL sanitization in ColdFusion

I have the unfortunate task of cleaning up a bunch of old ColdFusion code. Queries are all over the place, I am working on moving them all to common CFCs for easier maintenance. I am running into a problem because cfquery is automatically…
Kip
  • 107,154
  • 87
  • 232
  • 265
5
votes
2 answers

Retrieving long text (CLOB) using CFQuery

I am using CFQuery to retrieve the CLOB field from Oracle DB. If the CLOB filed contains the Data less than ~ 8000, then I can see retrieved the value ( the o/p), however If the value in CLOB field size is more than 8000 chars,…
CFUser
  • 2,295
  • 5
  • 32
  • 37
5
votes
4 answers

How can I use query-of-query UNION on n-recordsets when var scoping is needed?

I would like to be able to do a query of a query to UNION an unknown number of recordset. However when doing a query-of-query dots or brackets are not allowed in record set names. For example this fails:
Dan Roberts
  • 4,664
  • 3
  • 34
  • 43
1
2 3
16 17