0
Participant
,
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/td-p/477075
Nov 15, 2007
Nov 15, 2007
Copy link to clipboard
Copied
I need to write a SP for a search query from this ColdFusion
code. I am not sure how to transform the coldfusion if statements
in TSQL to where it can work. Any help would be appeciated.
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Advisor
,
Nov 15, 2007
Nov 15, 2007
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 ...
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 ...
Advisor
,
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/m-p/477076#M43306
Nov 15, 2007
Nov 15, 2007
Copy link to clipboard
Copied
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 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
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
cutie369
AUTHOR
Participant
,
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/m-p/477077#M43307
Nov 15, 2007
Nov 15, 2007
Copy link to clipboard
Copied
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advisor
,
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/m-p/477078#M43308
Nov 15, 2007
Nov 15, 2007
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
cutie369
AUTHOR
Participant
,
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/m-p/477079#M43309
Nov 16, 2007
Nov 16, 2007
Copy link to clipboard
Copied
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!
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advisor
,
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/m-p/477080#M43310
Nov 16, 2007
Nov 16, 2007
Copy link to clipboard
Copied
The SQL code I provided will generate the cfstoredproc and
cfprocparam tags for a given stored procedure.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
cutie369
AUTHOR
Participant
,
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/m-p/477081#M43311
Nov 17, 2007
Nov 17, 2007
Copy link to clipboard
Copied
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advisor
,
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/m-p/477082#M43312
Nov 18, 2007
Nov 18, 2007
Copy link to clipboard
Copied
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.
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
cutie369
AUTHOR
Participant
,
LATEST
/t5/coldfusion-discussions/converting-coldfusion-code-to-tsql/m-p/477083#M43313
Nov 18, 2007
Nov 18, 2007
Copy link to clipboard
Copied
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.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

