Re: how to get UPDATEXML function in postgresql as it works in oracle

From: Raghavendra <raghavendra(dot)rao(at)enterprisedb(dot)com>
To: saritha N <saritha(dot)0917(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: how to get UPDATEXML function in postgresql as it works in oracle
Date: 2013-07-29 15:40:38
Message-ID: CA+h6AhjAMyKGCSd8WFYOwW8vsWiMe_xZXLDw3M2ukp62FNV5NQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Jul 29, 2013 at 7:14 PM, saritha N <saritha(dot)0917(at)gmail(dot)com> wrote:

> Hi,
>
> I am new to postgresql.We are migrating our application from oracle to
> postgresql.We are using postgresql version 9.2.All most everything we are
> migrated but I am unable to write a function for UPDATEXML which works same
> as in oracle.Please help me to resolve .
>
> Are you looking in this way....

create table xdata(id int,xmlcode xml);
insert into xdata values (1,'<values>Infosys</values>');
insert into xdata values (1,'<values>Enterprisedb</values>');
insert into xdata values (1,'<values>Wipro</values>');

postgres=# select * from xdata ;
id | xmlcode
----+-------------------------------
1 | <values>Infosys</values>
1 | <values>Enterprisedb</values>
1 | <values>Wipro</values>
(3 rows)

postgres=# update xdata set xmlcode='<values>Infosys-Bangalore</values>'
where cast(xpath('//values/text()',xmlcode) as text[]) = '{Infosys}';
UPDATE 1
postgres=# select * from xdata ;
id | xmlcode
----+------------------------------------
1 | <values>Enterprisedb</values>
1 | <values>Wipro</values>
1 | <values>Infosys-Bangalore</values>
(3 rows)

---
Regards,
Raghavendra
EnterpriseDB Corporation
Blog: http://raghavt.blogspot.com/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tim Spencer 2013-07-29 16:37:59 Re: how _not_ to log?
Previous Message Tom Lane 2013-07-29 15:34:04 Re: 5 is not a smallint but '5' is