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
5
votes
2 answers

Using cachedwithin attribute inside cfquery

When you use the cachedwithin attribute in a cfquery how does it store the query in memory. Does it store it by only the name you assign to the query? For example, if on my index page I cache a query for an hour and name it getPeople will a query…
Jason
  • 17,276
  • 23
  • 73
  • 114
5
votes
2 answers

How can I get particular Row in a query variable using ColdFusion?

Take the following query example: Select * from Table_Test Assume that the "Test" query returns 10 rows. I want to show single row on current time. Note: I do not want to change the SQL…
Mohanrajan
  • 721
  • 9
  • 18
5
votes
4 answers

How can we add a new row in middle of a cfquery result?

I have a query result set from cfquery. I just want to add a new after a particular row number. But When tried each time it inserts the row at the end. Is there any way I can insert row at the middle of the query?
Deepak Kumar Padhy
  • 4,128
  • 6
  • 43
  • 79
5
votes
2 answers

Date Display problem in ColdFusion

When I retrived a Date field in TOAD it displayed like is '1/18/2038 9:14:07 PM', But when I rertrived in Coldfusion using cfquery and displayed using , then I got the date on screen like '2038-01-18 21:14:07.0'. Does anyone have idea why it…
CFUser
  • 2,295
  • 5
  • 32
  • 37
5
votes
3 answers

Tackling Null Values while Inserting data in data base

I have the following cfquery: INSERT INTO DatabaseName (PhoneNumber_vch, Company_vch, date_dt) VALUES(#PhoneNumber#, #Company#, …
Jack
  • 989
  • 3
  • 13
  • 24
5
votes
6 answers

How to Execute 2 or more insert statements using CFQuery in coldfusion?

Is it possible to Execute 2 insert or Update Statements using cfquery? If yes how? if no, what is the best way to execute multiple queries in Coldfusion, by opening only one Connection to DB. I think every time we call cfquery we are opening new…
CFUser
  • 2,295
  • 5
  • 32
  • 37
5
votes
3 answers

Coldfusion breaking an array into two

Can I split an array into two separated ones with each element in the original array separated by a ":"? The text before the ":" goes to array1, the text after ":" goes to array2
reZach
  • 8,945
  • 12
  • 51
  • 97
4
votes
1 answer

Getting value from cfquery when query column is a variable

I'm stuck... can't remember how to make this work. The code:
earachefl
  • 1,880
  • 7
  • 31
  • 55
4
votes
2 answers

Problem with a challenging algorithm

I'm stumped. I need to access the next nth row in a query loop to show version differences between posts. I'm using to output the revisions by group, and this is my expected output: Rev4 diff(rev4.title, original.title) …
Mohamad
  • 34,731
  • 32
  • 140
  • 219
4
votes
1 answer

Can not find the difference between accessing property in a query with '[bracket]' and '. dot' notation

I have a code snippet where I am fetching rows from a database and finding dateDiff from one of the columns in the query. SELECT [DateInvited] FROM [INVITE_PERSON] WHERE [UUID] = …
Bikash Das
  • 147
  • 1
  • 12
4
votes
1 answer

Does ColdFusion query has a limit of characters?

I have a MySQL database with a column datatyppe LONGTEXT. It has in the record 85.504 characters. When I do a select using coldfusion query, it only return the first 64,001 characters. Is ColdFusion limited to 64,001 characters? selectTest = new…
Code Guy
  • 105
  • 1
  • 7
4
votes
3 answers

How to set a dynamic key name in a struct with cfquery column?

I have structure where I want to replace currentRow key with cfquery column recID. This column is integer that is auto incremented in sql table. For some reason my code is failing to create structure with unique key. Here is my code:
espresso_coffee
  • 5,980
  • 11
  • 83
  • 193
4
votes
3 answers

How to use functions in Queries on Queries?

I want to implement something similar to IIF in the QoQ below. However it's giving me an error. Either I'm doing it wrong or it's just not possible. Hopefully, it's the former. select lastname + IIF(Len(firstname) > 0,…
mrjayviper
  • 2,258
  • 11
  • 46
  • 82
4
votes
2 answers

getting result metadata from coldfusion newQuery() in cfscript

Documentation on CFscript is a bit sparse in the docs, and searching for a cfscript specific answer gets lost in CF tag answers. So here's my question: How do I get the result metadata from a query that was performed using script? Using tags I can…
j-p
  • 3,698
  • 9
  • 50
  • 93
4
votes
2 answers

Good general purpose try/catch routine

Using Adobe ColdFusion version 8 and below, all my cfqueries are wrapped in a try catch that calls a function in database.cfc called "CatchError". UPDATE TableName SET ... WHERE ID =…
Phillip Senn
  • 46,771
  • 90
  • 257
  • 373
1
2
3
16 17