• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Q&A

Q1:I've designed an input form that assembles user selections into a list. I want to use the list to create a dynamic query, but my SQL statement requires that each list item appear in single quotes. What to do?
A1: When you use the list variable in your query, surround it with the function QuotedValueList, like this:
#QuotedValueList(form.variable)#

This will cause ColdFusion to insert single quotes around each item in your list.

Q2:How do I guard against errors if my query calls on an empty list, for example, if a user hits "submit" without typing anything into a search box?
A2: There are several solutions. The simplest is to use the <CFPARAM> tag on your results page to define a default value for your list. You might also use a <CFIF> ]statement that will only perform the query if the list has values in it. You can also design your form with the <CFFORM> tagset and use the REQUIRED parameter on all input boxes.
Q3:I've used lists, structures, and arrays in other programming languages. Are the ColdFusion versions similar?
A3: In concept, yes, although the ColdFusion versions have certain limitations versus those used in languages such as Perl and C.
Q4:Are there limits on the amount of data that can be stored in a list, structure, or array?
A4: In theory, no, but massive variables of any type can put a strain on your server in their extremes.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint