Created
June 17, 2016 18:46
-
-
Save alex-oliveira/b9f6a4101e6fd7d5680012aaeb955c5a to your computer and use it in GitHub Desktop.
Mult-Replace no PostgreSQL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT * | |
FROM ( | |
SELECT | |
R.id, | |
REPLACE( | |
REPLACE( | |
REPLACE( | |
REPLACE( | |
REPLACE( | |
REPLACE( | |
REPLACE( | |
REPLACE(A.mensagem, '{{this.link_id}}', COALESCE(NULLIF(json_extract_path_text(data_replaces::json, 'this.link_id'), ''), CAST(R.link_id as VARCHAR(20)))) | |
, '{{autenticacao.usuarios.nome}}', COALESCE(json_extract_path_text(data_replaces::json, 'autenticacao.usuarios.nome'), '')) | |
, '{{autenticacao.divisoes.divisao}}', COALESCE(json_extract_path_text(data_replaces::json, 'autenticacao.divisoes.divisao'), '')) | |
, '{{planejamento.fases.nome}}', COALESCE(json_extract_path_text(data_replaces::json, 'planejamento.fases.nome'), '')) | |
, '{{contract}}', COALESCE(json_extract_path_text(data_replaces::json, 'contract'), '')) | |
, '{{contract}}', COALESCE(json_extract_path_text(data_replaces::json, 'contract'), '')) | |
, '{{date}}', COALESCE(json_extract_path_text(data_replaces::json, 'date'), '')) | |
, '{{days}}', COALESCE(json_extract_path_text(data_replaces::json, 'days'), '')) AS msn | |
FROM caixa_alertas AS R | |
INNER JOIN alertas AS A ON R.id_alerta=A.id | |
) as X | |
WHERE msn like '%garantia #44%' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment