Solved

How to add quotes around parameters values

  • 30 September 2022
  • 6 replies
  • 178 views

Badge +6

I want to run a SQL before a writer to a postgis database.

I am using parameters to dynamically run the SQL queries. Since SQL is case sensitive and my tables include case characters I need to put quotations around my table names. But putting quotes around my statement make it a string. I just want to add quotes the parameters value.

select * from "$(schema)"."(fme_feature_type)"

Desired result

select * from "MySchema"."A_Table"

 

Is there a way to escape the quotes somehow to just add quotes around the paramaneter value.

icon

Best answer by nielsgerrits 30 September 2022, 14:18

View original

6 replies

The published parameter should work this way. If you want the fme_feature_type part dynamic, you need to use.

select * from "$(schema)"."@Value(fme_feature_type)"

 

Badge +6

I have tried that too. But FME execute it as 

Error executing SQL command ('Select * from MySchema.MyTable'):
'ERROR:  relation "MySchema.MyTable" does not exist'

I need the quotes to be part of the statement 

Select * from "MySchema"."MyTable"

 

 

 

I have tried that too. But FME execute it as 

Error executing SQL command ('Select * from MySchema.MyTable'):
'ERROR:  relation "MySchema.MyTable" does not exist'

I need the quotes to be part of the statement 

Select * from "MySchema"."MyTable"

 

 

 

Does it work when you use an AttributeCreator to create the code and put the attributevalue in the SQLCreator?

Userlevel 3
Badge +26

I suppose you could create the SQL query in an AttributeCreator as it is now. Then in a StringReplacer after that, replace . with "."

Userlevel 5

Try:

    select * from "$(schema)"."@Value(fme_feature_type)"

Be aware that the name of the published parameter is case sensitive.

Badge +6

Does it work when you use an AttributeCreator to create the code and put the attributevalue in the SQLCreator?

In closer inspection I think it actually work to do what you originally suggested. Not sure where i looked wrong. But it seem to be solved. It just look in the SQL dialog that the parameter will be evaluated as a string. Great! Thank you

Reply