7

I have a function in postgreSQL,One of my function argument is text type variable and that enclosed with in double quotes so i want to insert this variable to table with out double quotes ,when i search regarding this on net i got a query like SELECT trim(both ' ' from 'techonthenet.com'); but this not working in the case of double quotes so how will i remove double quotes from text string variable in postgreSQL function

Sherin Green
  • 308
  • 1
  • 3
  • 18

2 Answers2

17

It is working:

postgres=# select '"Hello"';
┌──────────┐
│ ?column? │
╞══════════╡
│ "Hello"  │
└──────────┘
(1 row)

postgres=# select trim(both '"' from '"Hello"');
┌───────┐
│ btrim │
╞═══════╡
│ Hello │
└───────┘
(1 row)
Pavel Stehule
  • 42,331
  • 5
  • 91
  • 94
2

Another simple solution would be:

SELECT REPLACE('"Hello"', '"', '');
Roman M
  • 8,849
  • 2
  • 15
  • 17