Ask a Question related to Coldfusion Database Access, Design and Development.
-
healey_mark #1
retrieve sql from database
Our organization has alot of SQL, and we prefer to be able to store our
application SQL in a DB; we find it easier to maintain that way.
What I would like to do:
<cfquery name="getstatement" datasource="#datasource#">
SELECT code from sqlcode where name='statement1'
</cfquery>
<cfquery name="aQuery" datasource="#datasource#">
#getstatement.code#
</cfquery>
The SQL code would be something like:
select dept_id, name
from departments
where name like <cfqueryparam cfsqltype="cf_sql_varchar" value="#NameSearch#"
maxlength="20">
The problem I have is getting the <cfqueryparam> to evaluate in the above
example.
Does anyone have a solution for this problem? Note that I cannot use stored
procedures.
healey_mark Guest
-
unable to retrieve or display images from sql database
Using Dreamweaver 8 and connecting to an Sql Server 2000 i am not able to display image files from the sql table. the other fields in the table are... -
how to retrieve swf file from database?
i m still new in this actionscript thingy. i know how to load external .swf file from the same folder to flash when it is call by using ... -
Two Function Calls to a Database to Retrieve the UniqueID of Inserted Records
Hi guys, I got the error message on Option 2 query as show. Actually, this code is from Inside ColdFusion MX boook. I just would like to know is... -
store and retrieve flash in and from database
Hi all, i stored an uploaded flash-file in a MS-SQL database. Now i want to retrieve this file from my database in ASP.NET, but I don't know how to... -
Retrieve n records from database
I came across a tutorial about a year ago that explained the answer I seek. Now, however, I cannot find the answer anywhere. I have a flash movie... -
MikerRoo #2
Re: Search bar error
You can try playing with the Evaluate() function but I believe you will find
that it's not possible to execute a tag like <cfqueryparam> this way.
If reverting to plain SQL, remember the PreserveSingleQuotes() function.
To store SQL and still be able to use parameterized queries, you'll might
pre-parse the SQL like so:
Create 2 tables:
1) Main SQL has at least these columns:
1.a) ID
1.b) Pre where-clause SQL text.
1.c) Post where-clause SQL text.
2) Parameterized Where-Clause table has at least these columns:
2.a) ID
2.b) FKey into table 1
2.c) SQL column name and operator, (EG. "name = ")
2.d) cfsqltype value
2.e) CF variable name
2.xxx ) Additional columns for additional attributes like maxlength.
Using these two tables you can build a parameterized SQL call.
Of course, fancy sub-selects, etc. could get messy.
-- MikeR
MikerRoo Guest
-
healey_mark #3
Re: retrieve sql from database
Thanks MikerRoo,
I came to the same conclusion: evaluate() doesn't work. I am left with
either a manual parsing solution (as you described), writing the SQL to a file
and including it, or using cfobject to work with the underlying java code.
I will give this more thought; I am mentioning my other ideas for the benefit
of anyone else who's facing a similar problem.
healey_mark Guest
-
MikerRoo #4
Re: retrieve sql from database
Hey healey_mark,
It looks like you saw the correct reply to this post?
Because now the reply has been overwritten with my post on another thread.
Can you confirm that you saw the correct reply at one point ?
Thanks,
-- MikeR
MikerRoo Guest
-
healey_mark #5
Re: retrieve sql from database
I saw the reply--fortunately the entire text is emailed when you make your post.
I'm reproducing it here in case anyone else is following the thread:
You can try playing with the Evaluate() function but I believe you will find
that it's not possible to execute a tag like <cfqueryparam> this way.
If reverting to plain SQL, remember the PreserveSingleQuotes() function.
To store SQL and still be able to use parameterized queries, you'll might
pre-parse the SQL like so:
Create 2 tables:
1) Main SQL has at least these columns:
1.a) ID
1.b) Pre where-clause SQL text.
1.c) Post where-clause SQL text.
2) Parameterized Where-Clause table has at least these columns:
2.a) ID
2.b) FKey into table 1
2.c) SQL column name and operator, (EG. "name = ")
2.d) cfsqltype value
2.e) CF variable name
2.xxx ) Additional columns for additional attributes like maxlength.
Using these two tables you can build a parameterized SQL call.
Of course, fancy sub-selects, etc. could get messy.
-- MikeR
healey_mark Guest
-



Reply With Quote

