Ask a Question related to Coldfusion Database Access, Design and Development.
-
ryanstewart #1
Setting a SQL Statement as a Variable and Running UsingCFQuery
I've got a table with a bunch of sql statements that I need to run and cfdump
the results to the screen. I have one <cfquery> tag that pulls the sql
statement out of the database based on an ID number given: <cfquery
name='retrieveSqlStatementToRun'> SELECT sql_statement as sqlData FROM Table1
WHERE statement_id = #sqlID# </cfquery> This works fine, and when I <cfdump>
or <cfoutput> the variable #retrieveSqlStatementToRun.sqlID# I see the SQL
statement I want to run: SELECT First_Name, Last_Name, Birthday FROM Table2
WHERE Last_Name = 'Smith' But when I set up the second <cfquery>, using only
the #retrieveSqlStatementToRun.sqlID# it gives me an 'Error Executing Database
Query' Here's the code for the second query: <cfquery name='runSqlStatement'>
#retrieveSqlStatementToRun.sqlData# </cfquery> Is there anything special I
need to do to run an entire SQL statment (the selects, from, and where) via one
Cold Fusion variable? Thank you! -Ryan
ryanstewart Guest
-
Setting a string to a conditional statement?
I want to allow users of my website to define there own custom queries using a form. The problem that i am running into is that cfset cannot handle... -
Setting a variable name with a variable in a loop
Here is the code that bombs: <cfloop index='x' from='1' to='10' step='1'> <cfif #evaluate('form.totalhours#x#')# eq 'r'> <cfset total_hours_#x# =... -
A variable in a php statement
Hi This works: <?php if (isset($_GET)) { echo '<input type='hidden' name='frm_catid' value='71'>'; } else { echo '<input... -
variable select statement
I would like to have a form that gives the user choices for selection parameters for email, printing etc. A real simple example: Give me all... -
#22558 [Com]: DB2 seems to be 10x slower than MYSQL running a simple select statement
ID: 22558 Comment by: port at iname dot com Reported By: danl at icarz dot com Status: Bogus Bug Type: ... -
kyle969 #2
Re: Setting a SQL Statement as a Variable and RunningUsing CFQuery
Try this:
<cfquery name='runSqlStatement'>
#preserveSingleQuotes(retrieveSqlStatementToRun.sq lData)#
</cfquery>
inside a cfquery block CF replaces ' with ', using this function prevents that.
kyle969 Guest
-
ryanstewart #3
Re: Setting a SQL Statement as a Variable and RunningUsing CFQuery
Works like a charm, thanks!
ryanstewart Guest



Reply With Quote

