This content has been marked as final. Show 8 replies
See sample below.
I reccommend "The Guru's Guide to Transact-SQL" and "The Guru's Guide to SQL Server Stored Procedures, XML, and HTML" by Ken Henderson if you're looking to learn TSQL beyond the SELECT, UPDATE, INSERT, DELETE statements.
edit: added COALESCE to 2nd part of WHERE clause
I tried your suggestion and it works great when I am using SQL Query analyzer. I get an empty query result set back set back on all Stored Procedure calls. I tried doing just a straight query and it works fine. Can you look over my code please and tell me what might be causing this.
The dbvarname is not supported in CF 6 or 7. I do not see it in the documentation for CF 8 either although it I read somewhere that it "may" be supported. There is also a hotfix for CF7 to enable support for dbvarname. http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400074
Without dbvarname you should specify all your parameters in the order they appear in the stored procedure's definition. To specify NULL as the value of a parameter set null="yes" in the cfprocparam.
To treat an empty string as NULL
<cfprocparam value="#form.myField#" cfsqltype="cf_sql_varchar" maxlength="50" null="#YesNoFormat(Trim(form.myField) eq '')#" />
To ease creating the cfstoredproc code block run this on your SQL server in SQL Management Studio with query results sent to text. You can then copy the output to your CF file. Note this was written for MS SQL 2005, but *should* work on 2000. You will need to add any desired cfprocresult tags.
Hi Bob, I am not sure what this T-SQL code is for? I was able to get my sp working with your help. Thanks, please give me some more information about the code you suggested that I run. Things are working nicely now. Thank you!
The SQL code I provided will generate the cfstoredproc and cfprocparam tags for a given stored procedure.
What a most useful peace of code? I have a question do you have any sample code using the MVC concept and Stored Procedures. I ordered the book that you suggested.
I don't have any MVC samples, but I do recommend that that use CFCs to make your code re-useable.
I may be reading too much into your question but If you are interested in a framework for ColdFusion I've heard good things about Mach II http://www.mach-ii.com/ and FuseBox http://www.fusebox.org/ but haven't used either in production.
Bob, thanks, I agree with you that CFC's are the way to go. I have been using them exclusively for the past year. I want to move towards doing object oriented applications and I was wondering if you had any examples of this doing stored procedures. Or not only you but anyone else who may be reading this. I have looked at MachII but it seems too difficult. I am not a huge fusebox fan either. Model Glue seems like the one I could wrap my arms around.