Skip to content
Advertisement

PostgreSQL escape characters when using Excel formula

I’d like to generate a query like this:

select id, '=FKERES(B2;'D:nyunyuka[kotyog.xlsx]Munka1'!$A:$B;2;0)' as
 excel_formula from table;

I learned that I have to escape the ' character using E but it seems not working. I assume that I have to escape all the as well. But It’s getting complicated to me.

Advertisement

Answer

I am not sure if I understood the question correct. Hope that I did. You need to add extra single quotes like this:

select id, '=FKERES(B2;''D:nyunyuka[kotyog.xlsx]Munka1''!$A:$B;2;0)' as excel_formula 
from table;

So, if there is a single quote ' in a string in a select clause then you have to add another one '' to make it work.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement