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

lcase, ucase and ??

Explorer ,
Jun 01, 2011 Jun 01, 2011

Hi,

i can check for lcase (test), ucase (TEST) but what's about Test?

  SELECT org FROM center

  WHERE center= <cfqueryparam value="#trim(lcase(form.center))#" cfsqltype="cf_sql_varchar" maxlength="50" > ---test
  or
  center= <cfqueryparam value="#trim(ucase(form.center))#" cfsqltype="cf_sql_varchar" maxlength="50" > ---TEST

or center= ????--Test?

Thanks

TOPICS
Getting started
799
Translate
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
LEGEND ,
Jun 01, 2011 Jun 01, 2011

There's no inbuilt function to do that.  However cflib.org almost certainly has a UDF that does...

--

Adam

Translate
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
LEGEND ,
Jun 01, 2011 Jun 01, 2011

Database functions upper() and lower() will work.  Having said that, using db functions in the where clause can really slow down production.  If there are some indexed fields you can use first, do so.

Translate
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 03, 2011 Jun 03, 2011

kt03 wrote:

Hi,

i can check for lcase (test), ucase (TEST) but what's about Test?

  SELECT org FROM center

  WHERE center= <cfqueryparam value="#trim(lcase(form.center))#" cfsqltype="cf_sql_varchar" maxlength="50" > ---test
  or
  center= <cfqueryparam value="#trim(ucase(form.center))#" cfsqltype="cf_sql_varchar" maxlength="50" > ---TEST

or center= ????--Test?

Place this line before the cfquery tag:

<cfset centerfield = trim(form.center)>

Then apply:

WHERE center = <cfqueryparam value="#ucase(left(centerfield, 1)) & right(centerfield,len(centerfield) - 1)#" cfsqltype="cf_sql_varchar" maxlength="50" >

Translate
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
Guide ,
Jun 03, 2011 Jun 03, 2011

Does your database not support function-based indexing? This is what I'd do in Oracle:

CREATE INDEX center_whatever_idx

ON center ( UPPER(org) ) ;

That's then created an index on the upper-case version of your column. You can then just search for it in uppercase:

<cfquery>

  SELECT something

  FROM center

  WHERE UPPER(center) = <cfqueryparam cfsqltype="cf_sql_varchar" value="#upper(myval)#" />

</cfquery>

And that'll use your index. I haven't tested it, but I'd be willing to bet it's a million times quicker.

Translate
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
LEGEND ,
Jun 03, 2011 Jun 03, 2011
LATEST

How would that approach work with these values?

John Paul Jones

McBean

Translate
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