简体   繁体   中英

How to trim double quotes from string variable in postgreSQL function

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

It is working:

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

postgres=# select trim(both '"' from '"Hello"');
┌───────┐
│ btrim │
╞═══════╡
│ Hello │
└───────┘
(1 row)

Another simple solution would be:

select replace ('"Hello"', '"', '');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM