Oracle的sql语句中,单引号'可以做转义字符。
如果需要拼接带单引号(')的字符串,则需要用两个单引号(''),其中一个单引号作为转义字符使用。
-------------------------------------------------------------------------------------------------------------------
例子:
select 'update t_ph_pf_check_item set item_goal_demand=' || '''' || item_goal_demand || '''' || ' where item_code= ' || ''''|| item_code ||''''||';' from t_ph_pf_check_item i where i.item_goal_demand like '%$%';
sql结果:
update t_ph_pf_check_item set item_goal_demand='$year$年城乡居民健康档案规范化电子建档率≥$value$%。' where item_code= 'ehr';