Basic HTML version of Foils prepared May 3 1998

Foil 54 Dynamic SQL - II

From Java Blend and Cold Fusion High Level Database Interfaces CPS616 Web Technologies -- Spring 98. by Chao Wei Ou


1 For example, in the following code, a series of CFIF tags determine which SQL statements to append to the base SQL SELECT statement:
2 <CFQUERY NAME="EmpList" DATASOURCE="CF 3.0 Examples">
3 SELECT * FROM Employees WHERE 0=0
4 <CFIF #LastName# is not "">
5 AND LastName = '#LastName#'
6 </CFIF>
7 <CFIF #FirstName# is not "">
8 AND FirstName LIKE '%#FirstName#%'
9 </CFIF>
10 </CFQUERY>
11 Tip: The WHERE 0=0 clause has no impact on the query submitted to the database. But if none of the conditions is true, it ensures that the WHERE clause does not result in a SQL syntax error.

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sat Nov 28 1998