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
4
votes
1 answer

How can I perform a SQL SELECT with a LIKE condition for a string containing an open bracket character?

I have a simple search query: SELECT * FROM MyQoQ WHERE DESCRIPTION LIKE '%#URL.searchString#%' This query works excellently for most values. However, if someone…
Eric Belair
  • 10,574
  • 13
  • 75
  • 116
4
votes
2 answers

access variables from Appliction.cfc

I would like to know the new way of calling variables from the Application.cfc file when using the script function, which has the format of "this.something" My example: component { // application variables this.datasource = "my…
4
votes
2 answers

Selecting A row range from a query of queries

How would I select a specific range of rows using a query of queries? e.g SELECT * FROM previous_query WHERE row_numer >= 12 that sort of thing...
Dpolehonski
  • 948
  • 6
  • 11
4
votes
2 answers

CFQUERY times out when using cfqueryparams and MSSQL Server?

I'm executing a query that returns about 16000 rows. Running the straight SQL in MS SQL Server Manager returns the records in a few seconds. Running the same SQL in cfquery returns it in about the same time. The query is composed with a few…
Danomite
  • 369
  • 3
  • 16
3
votes
2 answers

Excess Characters Being Generated by ColdFusion Query/output

I've got a strange issue with some Coldfusion/SQL Query output. The actual data is generating properly, but at the bottom of the page it's outputting "Library/Library/Library/Library/Library/Library/Library/Library" for no reason I can discern. It…
EepMoody
  • 124
  • 10
3
votes
1 answer

Is it possible to dynamically call a cfquery variable?

I'm going through a query in which there are 12 entries named "choice_1" through "choice_12." I want to be able to dynamically call an individual choice depending where it is in the loop. So here is the query:
Anthony Tantillo
  • 300
  • 1
  • 3
  • 12
3
votes
2 answers

cfquery name attribute, optional?

Is name attribute of cfquery optional? The doc said it is required, but my code seems to run fine even without it. Is there a default value if not defined? and if so, shall I local var it or safely ignore it? Thx
Henry
  • 32,689
  • 19
  • 120
  • 221
3
votes
5 answers

Creating nested

This seems like a pretty common task I want to do, but I can't wrap my head around the cfloops and cfqueries. I have a database full of photo galleries. They all have an ID and a ParentID (except the root galleries - their ParentID is blank), and…
Michael
  • 2,546
  • 2
  • 20
  • 26
3
votes
5 answers

How do I programmatically sanitize ColdFusion cfquery parameters?

I have inherited a large legacy ColdFusion app. There are hundreds of some sql here #variable# statements that need to be parameterized along the lines of: some sql here How…
Nathan Feger
  • 19,122
  • 11
  • 62
  • 71
3
votes
1 answer

Coldfusion - Refreshing Page When A Database Record Updates

Good day, Let me describe my problem : Scenario : User 1 has a coldfusion webpage, containing 6 alerts as html elements populated using a database. User 1 is constantly monitoring this page for changes. A user on a different computer (different…
Simon Erasmus
  • 134
  • 12
3
votes
2 answers

Using ColdFusion to show Chinese Characters from AS/400 server

I am writing a ColdFusion program that uses cfquery to get data from an AS/400 iSeries table and then output that data to a web page. Some times the Data is in Chinese, but it does not output the Chinese characters correctly. I built the query below…
MHall
  • 31
  • 2
3
votes
2 answers

ColdFusion: SQL Select IN from a Query

I have a SQL Server query which returns two values for one MyBusinessUnit column returns two values, say: 1111 2222 in a query object called MyQuery1 Both of these values also exist in a DB2 database's MyCorpUnit column. What I want is to select all…
IrfanClemson
  • 1,699
  • 6
  • 33
  • 52
3
votes
0 answers

passing 2 values from cfselect based on selection from dropdown?

This is only my second question on SO, and I'm brand new to web coding of all kinds (anything I've done I've picked up within the last 3 weeks so I don't really know what I'm doing) but here's some background and my issue: Background info: I'm…
Becalecca
  • 203
  • 1
  • 12
3
votes
2 answers

ColdFusion single quote issue with SQL Query

In my ColdFusion 11 app, with SQL Server 2008-R2, I've following cfquery tag inside a CF Component: select name, state from myTable #REReplace(where_clause,"''","'","ALL")# …
nam
  • 21,967
  • 37
  • 158
  • 332
3
votes
2 answers

Using column names from dynamically named variables in Coldfusion

I want to create a function that will loop through an arbitrary query and perform an insert into another table based on the arbitrary column names. For instance, the idea here would be to output (data, data, data...) (data, data,…
abalter
  • 9,663
  • 17
  • 90
  • 145
1 2
3
16 17