cfquery

Is it possible to have dynamically generated query names in ColdFusion?

限于喜欢 提交于 2019-12-24 04:58:51
问题 What I am trying to do is <cfloop array="#LOCAL.someArray" index="LOCAL.aString"> <cfset LOCAL.queryName = "uniqueQueryName_" & LOCAL.aString /> <cfquery name="#LOCAL.queryName#" datasource="db" cachedwithin="#CreateTimeSpan(1,0,0,0)#"> SELECT count(*) AS c FROM someTable </cfquery> <cfdump var="#LOCAL.queryName#" /> </cfloop> is this possible, or is there a better way to do it? Edit This works with <cfloop query="LOCAL.queryName"> but not when I try to do <cfset ArrayAppend(LOCAL.returnArray

Selecting A row range from a query of queries

▼魔方 西西 提交于 2019-12-21 17:44:41
问题 How would I select a specific range of rows using a query of queries? e.g <cfquery name="myQuery" maxrows ="20" startrow="12"> SELECT * FROM previous_query WHERE row_numer >= 12 </cfquery> that sort of thing... 回答1: This was a tricky one but your problem intrigued me. I think I may have a solution I wrote a function that delete everything prior to the rows you want and then deletes everything after the rows you want. the function rowrange() takes 3 parameters. 1. the queryname you are working

define a list of id's for grouped item

时光总嘲笑我的痴心妄想 提交于 2019-12-20 05:38:29
问题 i got a little question, i just can't understand, what is the problem and how do i solve it, i have a coldfusion variable, for example #account_code# , first of all, this code looks like this: 100.001.001 (there are bunch of them of cource) and i have some values for this variable, like sum(nettotal) and the cfquery i grouped by this #account_code# , all i want is to set the list of these codes, thus i define list, for example <cfset code_list='100.001.001,100.001.002'> and in query: account

ColdFusion how to set form input values from the results of a cfquery?

会有一股神秘感。 提交于 2019-12-20 03:23:39
问题 Question: (part 1) I am looking for the most efficient way to set my form input values based on the results of my cfquery . My form fields all match the column names in the database. I know using cfinsert I can update the database with form input values. Is there a way to do that in reverse? (part 1.5) How do I set the values of select and radio buttons based on the value of my cfquery? Background: I have a form with 60+ inputs with a mixture of text , select , radio and textarea . The page I

how can I use AngularJS and a serializeJSON cfquery

一笑奈何 提交于 2019-12-20 01:56:04
问题 I am trying to take a look at AngularJS, with a cf backend I have the following code that pulls a regular cfquery called getIndex which pulls five rows of columns each (firstName, lastName) var theQuery = <cfoutput>#serializeJSON(getIndex,true)#</cfoutput>; var theData = theQuery.DATA function dataLooper($scope){ $scope.people = theData; console.log($scope.people); } the console log produces Object { FIRSTNAME=[5], LASTNAME=[5]} my html looks like <div ng-controller="dataLooper"> <div ng

How to access a scope if its name is being used as a query column

╄→尐↘猪︶ㄣ 提交于 2019-12-19 09:49:57
问题 Dealing with some legacy code we came across a rather annoying situation. We are looping through a query with the <cfoutput query="x"> tag. That query has a column named 'url'. Within that loop we need to check if a key exists within the url scope. Since CF puts a priority on what's in the query over general page scopes I can't use a structKeyExists(url,"key") since as far as CF is concerned at this point, url is a string with the value from the current row of the query. How can I break out

cfquery crashes when there are tsql comments

北城以北 提交于 2019-12-19 06:18:53
问题 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 employees This works OK in both SELECT * FROM dbo.Roles WITH (NOLOCK) WHERE Code IS NOT NULL AND Active = 1 AND RoleID IN (SELECT RoleID FROM dbo.Emp WITH (NOLOCK)) Is there a setting to restore the orginal behavior? UPDATE I thought I had a minimal example of

How to override SQL sanitization in ColdFusion

浪子不回头ぞ 提交于 2019-12-18 16:59:21
问题 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 converting the single quotes to double-single-quotes. How can I override that behavior? More specific information is below. So here is the query I started with: <cfquery name="getObjectInfo" datasource="#BaseDS#"> SELECT groupName AS lastname, '[Group]' AS

Creating a stored procedure in MySQL5 with ColdFusion 9's <CFQUERY>-Tag

假装没事ソ 提交于 2019-12-13 15:22:49
问题 I wonder if it's possible to create a stored procedure in MySQL5 via ColdFusion's <cfquery> -tag. I've never done anything with storedprocedures before... I was trying to set a function which replaces like MySQL's REPLACE but case insensitive. I wanted to use the function provided here. But first I want to create this function via Coldfusion like: <CFQUERY datasource="#dsn#"> DELIMITER $$ DROP FUNCTION IF EXISTS `replace_ci`$$ CREATE FUNCTION `replace_ci` ( str TEXT,needle CHAR(255),str_rep

Unable to access JavaScript variables in ColdFusion tags in script

蹲街弑〆低调 提交于 2019-12-13 08:41:30
问题 I was trying to take the selected value from the select tag and pass it to cold fusion tags in jquery as follows. select tag code: <select id="selectco"> <cfoutput query="colist"> <option value="#cid#">#coname#</option> </cfoutput> </select> jQuery code: $(document).ready(function() { $("#selectco").change(function() { var e=document.getElementById("selectco"); var opt=e.options[e.selectedIndex].value; $("#selectst").html("<cfquery name='stlist' datasource='tasks'> select * from state where