• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Problem with ListChangeDelims()

New Here ,
Jun 05, 2006 Jun 05, 2006

Copy link to clipboard

Copied

I can't get CF to return the results that I want... is there anything wrong with this code?

<cfif isDefined('form.ICNumber')>
<cfquery name="findRegistrant" datasource="registrationdb" dbtype="odbc">
SELECT partner.*
FROM partner
WHERE 'ListChangeDelims(partner.ICNumber,"","-")' = '#ListChangeDelims(AppendICNumber,"","-")#'
</cfquery>
</cfif>
TOPICS
Advanced techniques

Views

549

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 06, 2006 Jun 06, 2006
Assuming '123456-45-9876' and '123456459876' are the only two possible representations,

<cfset ic_no = Replace(AppendICNumber,"-","","all")>
cfif isDefined("form.ICNumber")>
<cfquery name="findRegistrant" datasource="registrationdb">
SELECT *
FROM partner
where ICNumber = '#AppendICNumber#' OR ICNumber = '#ic_no#'
</cfquery>
</cfif>



Votes

Translate

Translate
Advisor ,
Jun 05, 2006 Jun 05, 2006

Copy link to clipboard

Copied

There are many things wrong with that code.

The biggest problem is trying to use a CF function, ListChangeDelims, as a SQL operator.

You need to use string functions provided by by whatever RDBMS you are using.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2006 Jun 06, 2006

Copy link to clipboard

Copied

Can you give me a sample code? I'm using ODBC (Ms Access).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2006 Jun 06, 2006

Copy link to clipboard

Copied

There should be a reason, after all, for testing whether the form field exists.

<cfif isDefined("form.ICNumber")>
<cfquery name="findRegistrant" datasource="registrationdb">
SELECT *
FROM partner
where ICNumber = '#form.ICNumber#'
</cfquery>
</cfif>
(assumes ICNumber and form.ICNumber are strings)




Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2006 Jun 06, 2006

Copy link to clipboard

Copied

WHERE 'ListChangeDelims(partner.ICNumber,"","-")' = '#ListChangeDelims(AppendICNumber,"","-")#'

The reason why i did this is because the ICNumber stored in my DB can be either be something like '123456-45-9876' or 123456459876. A user can either key in something like'123456-45-9876' or 123456459876. They are both fundametally the same data keyed in differently with the hyphen. So how can I get ColdFusion to still return the results whether the user runs a search with or without those hyphen?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 06, 2006 Jun 06, 2006

Copy link to clipboard

Copied

Assuming '123456-45-9876' and '123456459876' are the only two possible representations,

<cfset ic_no = Replace(AppendICNumber,"-","","all")>
cfif isDefined("form.ICNumber")>
<cfquery name="findRegistrant" datasource="registrationdb">
SELECT *
FROM partner
where ICNumber = '#AppendICNumber#' OR ICNumber = '#ic_no#'
</cfquery>
</cfif>



Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2006 Jun 06, 2006

Copy link to clipboard

Copied

Thanks... that could work too...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 07, 2006 Jun 07, 2006

Copy link to clipboard

Copied

LATEST
!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation