From: | emmanuel(dot)remy94(at)icloud(dot)com |
---|---|
To: | celati Laurent <laurent(dot)celati(at)gmail(dot)com> |
Cc: | pgsql-fr-generale <pgsql-fr-generale(at)postgresql(dot)org> |
Subject: | Re: Postgresql : effecteur des update avec un champ XML ? |
Date: | 2024-12-17 08:03:22 |
Message-ID: | A44B1925-BD1D-463F-B6C7-AA2887925AC6@icloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-fr-generale |
Hello,
Je crois bien que cela nécessite de travailler sur du texte qui sera ensuite re-parsé en XML.
Quelque chose comme:
UPDATE public.metadata
SET data = xmlparse(DOCUMENT
REPLACE(
xmlserialize(CONTENT data AS TEXT),
'<gco:CharacterString>Ancienne Valeur</gco:CharacterString>',
'<gco:CharacterString>Nouvelle Valeur</gco:CharacterString>'
)
)
WHERE id = 1;
Bonne continuation,
Emmanuel
CASDEN
>
> Le 16 déc. 2024 à 22:18, celati Laurent <laurent(dot)celati(at)gmail(dot)com> a écrit :
>
>
> Bonjour,
>
> Je travaille avec postgreSQL. J'ai une table avec plusieurs colonnes. L'une d'elles (la colonne 'data') est une donnée de type XML. Savez-vous si il y aurait un moyen de faire des mises à jour/update sur cette colonne XML ? Pour exemple, je colle une requête qui fonctionne permettant d'extraire certains éléments de cette colonne XML.
>
> select id, unnest(xpath(
> '//cit:CI_Organisation/cit:name/gco:CharacterString/text()',
> CAST(data AS XML),
> ARRAY[
> ARRAY['cit', 'http://standards.iso.org/iso/19115/-3/cit/2.0'],
> ARRAY['gco', 'http://standards.iso.org/iso/19115/-3/gco/1.0'],
> ARRAY['mdb','http://standards.iso.org/iso/19115/-3/mdb/2.0'],
> ARRAY['cat','http://standards.iso.org/iso/19115/-3/cat/1.0'],
> ])) as orga_name, changedate, createdate, displayorder, doctype, extra, popularity, rating, root, schemaid, title, istemplate, isharvested, harvesturi,
> harvestuuid, groupowner, metadata.owner, metadata.source, uuid
> from public.metadata
> Existerai-t-il un moyen d’effectuer une mise à jour/update sur ce champ XML ?
> Un grand merci.
From | Date | Subject | |
---|---|---|---|
Next Message | Guillaume Lelarge | 2024-12-17 08:38:31 | Re: Postgresql : effecteur des update avec un champ XML ? |
Previous Message | celati Laurent | 2024-12-16 16:33:14 | Postgresql : effecteur des update avec un champ XML ? |