Allow multiple queries in a single CFML's cfquery

Not really under the hood but within the MySQL JDBC driver settings Railo give you an option to cut down your code and (without proof) hopefully reduce some IO with your server by allowing the use of ";" to delimit multiple queries during one <cfquery> block.

One way I have used this is in an import script I am running for a project.

DELETE * FROM newdb.users; ALTER TABLE newdb.users AUTO_INCREMENT = 1; INSERT INTO newdb.users (id,username,password) SELECT (id,username,password) FROM olddb.users

Don't be fooled, this isn't like Stored Procedures where you can return multiple record sets but it does mean you can tidy up some code and utilise one call to your DB server.

comments powered by Disqus