Hi Barry,

> executing StoredProcs are always faster than executing inline SQL (in the
> code) - for the same query

As Geoff said, stored procs are always going to be faster. But if you just
want to do some basic SQL with dynamic variables, have a look at the <cfqueryparam> 
tag.
This tag converts CF variables in SQL statements to Bind parameters, which
means that the static part of your SQL statement can be compiled for
faster performance.

eg. Lets say you had this query...
<cfquery name="qGetEmp" datasource="xyz">
SELECT * FROM Employees
WHERE EmployeeID = #x#
</cfquery>

You should write it like this...
<cfquery name="qGetEmp" datasource="xyz">
SELECT * FROM Employees
WHERE EmployeeID = <cfqueryparam value="#x#" cfsqltype="CF_SQL_INTEGER">
</cfquery>

There are 2 benefits to writing dynamic SQL this way -
1. It allows you to validate that your dynamic variable is the right
datatype. Very important if it's a URL or Form variable
2. Any decent database (SQL Server, Oracle) will compile the first part of
the SQL statement and subsequent calls will be faster.

HTH

Tim

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to