sql - regexp_replace instead of TRIM -


edit - complete rewrite per user comments. first post here - trying right.

i looking use regex_replace instead of trim in following.

select         'update '||quote_ident(c.table_name)||' set '||c.column_name||'=trim('||quote_ident(c.column_name)||')           '||quote_ident(c.column_name)||' ilike ''% '' ' script (         select             table_name,column_name                     information_schema.columns                      table_name 'my_%' , (data_type='text' or data_type='character varying')      ) c; 

which generates statement:

update my_table set my_field=trim(my_field); 

the goal generate following statement:

update my_table set my_field=regexp_replace(my_field, '\s+$', ''); 

but attempt:

select                 'update '||quote_ident(c.table_name)||' set '||c.column_name||'=regexp_replace('||quote_ident(c.column_name)||', '\s+$', '')                   '||quote_ident(c.column_name)||' ilike ''% '' ' script         (                 select                     table_name,column_name                                     information_schema.columns                                      table_name 'my_%' , (data_type='text' or data_type='character varying')              ) c; 

is generating following error:

error:  syntax error @ or near "\"     line 2: ...regexp_replace('||quote_ident(c.column_name)||', '\s+$', '')...                                                                  ^ 

hoping gain little clarity in why not working. thank you.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -