我有以下查询
SELECT email_text INTO v_result
FROM test.record_notification
WHERE record_notification_id = p_recordnotification_id;
返回以下结果
[br /] [br /] [br /]记录ID:记录名称:标题ID:标题名称[br /] [ul] http:// localhost:8080 / myproject / ShowRecords.action?recordsVO.recordId = 3324& recordId = 3324& status = Record Requested> 3324:DEV:test contract:2448730:Titanic [/ ul]
但是我想添加" [th]" " [/日]"在上面的结果中,最终字符串变为
[br /] [br /] [br /] [th]记录ID:记录名称:标题ID:标题名称[br /] [/ th] [th] http:// localhost:8080 / myproject / ShowRecords.action?recordsVO.recordId = 3324& recordId = 3324& status = Record Requested> 3324:DEV:test contract:2448730:Titanic [/ th]
请注意,可以有多个这样的记录。
请在PostgreSQL中建议一种方法
答案 0 :(得分:1)
按
替换您的查询SELECT '[br/] [br/] [br/]<th>' || replace(replace(email_text,'[br/]',''),'ul','th') INTO v_result
FROM test.record_notification
WHERE record_notification_id = p_recordnotification_id;
我假设你只有一个记录的问题 感谢
<强> [编辑] 强>
如果您不担心 br ,那么就这样做
SELECT '<th>' || replace(replace(email_text,'[br/]',''),'ul','th') INTO v_result
FROM test.record_notification
WHERE record_notification_id = p_recordnotification_id;
它将在99%的情况下工作