Highlighted

Delimit field name for cfinsert, cfupdate

New Here ,
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

327

Likes

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

Delimit field name for cfinsert, cfupdate

New Here ,
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

328

Likes

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

 

^ _ ^

Likes

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
Reply
Loading...
Mar 30, 2020 1
Adobe Community Professional ,
Mar 30, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Mar 30, 2020 1