Skip to main content
Solved

Case statement in SQL Creator Update Query

  • October 22, 2013
  • 4 replies
  • 43 views

I'm trying to update a value in a field to a new value based on a case statement. I'm using SQL Creator to do this.

 

 

I can update a field just fine with Update [Table] Set [Field] = "PASS".

 

But if I  try to set the field equal to a case statement I get an error that says "Provider error `(-2147217900) Syntax error (missing operator) in query expression '(case when".

 

 

Here is the exact query I'm using:

 

Update [TableName] set [Sector Lat Valid] = case when [RBS Lat] is null then "NA" when [RBS Lat]>=0 and [RBS Long]<=90 then "PASS" else "FAIL" end

 

 

Does anyone have an idea what I'm doing wrong? Thanks in advance?

Best answer by david_r

Hi,

 

 

the syntax of the SQLCreator / SQLExecutor is not specific for FME, it follows the underlying database. So the syntax may be different between Oracle and SQL Server, for example.

 

 

Since you're referencing table names using brackes "[ ... ]", I'm suspecting that you're using MS Access? If that is so, Access does not support CASE statements, you will have to translate into an IIF function. See here for a discussion with examples.

 

 

David
View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

takashi
Contributor
Forum|alt.badge.img+19
  • Contributor
  • October 22, 2013
Hi,

 

 

Try using single quotations '<value>' instead of double quotations "<value>".

 

 

Takashi

  • October 23, 2013
Unfortunately I get the same error whether I use single or double quotations.

david_r
Evangelist
  • October 23, 2013
Hi,

 

 

the syntax of the SQLCreator / SQLExecutor is not specific for FME, it follows the underlying database. So the syntax may be different between Oracle and SQL Server, for example.

 

 

Since you're referencing table names using brackes "[ ... ]", I'm suspecting that you're using MS Access? If that is so, Access does not support CASE statements, you will have to translate into an IIF function. See here for a discussion with examples.

 

 

David

  • October 23, 2013
Perfect! Worked like a charm! Thanks!

Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings