我有一個問題:下面是一條存盤在 postgres 表列中的錯誤訊息,我想從這個字串中只提取字串的一部分,在 Postgres 中可以這樣做嗎?
我想看看odoo.exceptions.ValidationError: ('No MRP template was found for MO/10881!', None)'只有這一部分。
一般來說,所有以 odoo.exceptions.ValidationError: 開頭的文本直到結尾
我該怎么做 ?有什么想法或建議嗎?
'Traceback (most recent call last):
File "/opt/src/addons_OCA/queue/queue_job/controllers/main.py", line 101, in runjob
self._try_perform_job(env, job)
File "/opt/src/addons_OCA/queue/queue_job/controllers/main.py", line 61, in _try_perform_job
job.perform()
File "/opt/src/addons_OCA/queue/queue_job/job.py", line 466, in perform
self.result = self.func(*tuple(self.args), **self.kwargs)
File "/opt/src/addons/costs/models/mrp_production.py", line 163, in trigger_calculate_all_costs
self.calculate_all_costs()
File "/opt/src/addons/sucosts/models/costline_mixin.py", line 284, in calculate_all_costs
rec.generate_service_products()
File "/opt/src/addons/mrp_product_templates/models/mrp_production.py", line 660, in generate_service_products
MO=self.name)))
odoo.exceptions.ValidationError: ('No MRP template was found for MO/10881!', None)'
uj5u.com熱心網友回復:
您可以使用regexp_replace函式搜索特定文本,然后選擇以下文本。
regexp_replace 函式為匹配 POSIX 正則運算式模式的子字串提供新文本的替換。它的語法為 regexp_replace(source, pattern, replacement [, flags ])。如果與模式不匹配,則源字串將原樣回傳。...
在這種情況下,您似乎需要ValidationError:之后的文本。類似的東西:(見演示)
select regexp_replace (message, '.*ValidationError:(.*)','\1')
from test;
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/478879.html
標籤:PostgreSQL
