Skip to main content
July 6, 2009
Question

Concatenate DropDown from DB2

  • July 6, 2009
  • 1 reply
  • 1024 views

Hi,

I am trying to concatenate values from two columns in a DB2 table and populate a dropdown list with it:

testForm.cfm:

<html>
<head>
<title>Input form</title>
</head>
<body>
<cfquery name="getBranch" datasource="AXMISC_SURVEY">
    SELECT (BRANCH_NUM CONCAT BRANCH_NAME)
INTO BRANCHINFO
    FROM SURVEY.BRANCH
</cfquery>

<!--- Define the action page in the form tag.
    The form variables pass to this page
    when the form is submitted --->

<cfform action="testAction.cfm" method="post">

<!--- List box. --->
Branch
<!--- <cfset optsize=getBranch.recordcount + 1> --->
<cfselect name="Branch" query="getBranch" value="BRANCH_NUM" size=11 display="BRANCHINFO">
<!---    <option value="">Select All   --->
</cfselect>

<!--- Reset button. --->
<cfinput type="reset" name="ResetForm" value="Clear Form">

<!--- Submit button. --->
<cfinput type="submit" name="SubmitForm" value="Submit">
</cfform>
</body>
</html>

_______________________________________________________

testAction.cfm:

<html>
<head> <title>Insert Survey Form</title> </head>
<body>

<!--- Insert the new record --->

<cfquery datasource="AXMISC_SURVEY">
   INSERT INTO SURVEY.CAF_SURVEY
   (SURVEY_DATE)
   VALUES
   (
<cfqueryparam cfsqltype="cf_sql_date" value="#form.SURVEY_DATE#">
   )
</cfquery>

<!--- <cfoutput>You have added #CONTACT_NAME# to the
Client Survey database.
</cfoutput>   --->
</body>
</html>

Code samples are greatly appreciated.

Thank you,

Jeanne Langfeldt

This topic has been closed for replies.

1 reply

Inspiring
July 6, 2009

First, your db2 documentation will show you the correct syntax for the concat function.  If you don't have any, google "db2 concat".

Next, why are you doing a select into instead of a simple select?

Finally, this,

<cfselect name="Branch" query="getBranch" value="BRANCH_NUM" size=11 display="BRANCHINFO">
looks like a better idea than what you say you are attempting.