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

Delimit field name for cfinsert, cfupdate

New Here ,
Mar 29, 2020 Mar 29, 2020

Copy link to clipboard

Copied

Hi there,

I have a table with a field name called currency.  Currency is a keyword and normally I have to delimit the field name in a query, eg update table set [currency] = 'USD'

 

When I use cfinsert with the currency field, I get query syntax error.  I wonder if I there is a way I can tell cfinsert to delimit the field?

 

Right now, I just left the currecy field out of cfinsert and run another update afterwards.

 

I am using CF18

 

Thanks

Views

399

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
LEGEND ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

Hi, kkcchan,

 

A perfect example of why to not use keywords as column names, function names, etc.  {shrug}

 

I've heard both sides of the arguments concerning cfinsert and cfupdate security.  Personally, I do not use them.  Your most likely workaround for this is to create the query manually and not use cfinsert/cfupdate.

 

In the future, when designing a database, it's best to avoid keywords and either shorten them or somehow abbreviate them.  So, "Currency" could be "crncy", or some such.  Even with delimiting them, it's not what I would consider "best practice."

 

V/r,

 

^ _ ^

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 ,
Mar 30, 2020 Mar 30, 2020

Copy link to clipboard

Copied

LATEST

I'm going to second Wolfshade's recommendation not to use keywords. This is always going to make things more confusing. Instead of shortening them, though, you might want to make them longer! For example, when you say "currency", you could make it "currency_used" or something that better describes the field's purpose.

 

I would also recommend that you take this opportunity to ditch CFINSERT and CFUPDATE. These might seem to save you a little bit of time, but you're better off just writing the SQL yourself. You've discovered one of the many reasons for that.

 

Dave Watts, Eidolon LLC

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