Обсуждение: how to get UPDATEXML function in postgresql as it works in oracle
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 .
Thanks & Regards,
Saritha
On Jul 29, 2013, at 15:44, saritha N <saritha.0917@gmail.com> wrote: > I am new to postgresql.We are migrating our application from oracle to postgresql.We are using postgresql version 9.2.Allmost everything we are migrated but I am unable to write a function for UPDATEXML which works same as in oracle.Pleasehelp me to resolve . I'm sure many of use would love to help you, but most people in here use Postgres instead of Oracle and are not all thatlikely to know what the UPDATEXML function does. They might also not really feel the need to go look that up for youon the internet. Perhaps you would care to explain? I think that increases your chances of getting an answer ;) Alban Hertroys -- If you can't see the forest for the trees, cut the trees and you'll find there is no forest.
On Mon, Jul 29, 2013 at 7:14 PM, saritha N <saritha.0917@gmail.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
On Tue, Jul 30, 2013 at 9:51 AM, saritha N <saritha.0917@gmail.com> wrote:
Thanks for your reply Raghavendra,
Thanks for the update.
Request to mark postgresql group email while replying so it will help much if other's have better idea as well if any correction in my test case.
Whatever you have sent its very useful for me.I need to add one more node between the values,like<values>Infosys<place>Bangalore</place></values>How to add?
postgres=# update xdata set xmlcode='<values>Infosys<place>Bangalore</place></values>' where cast(xpath('//values/text()',xmlcode) as text[]) = '{Infosys}';
UPDATE 1
postgres=# select xmlparse(content xmlcode) from xdata ;
xmlparse
--------------------------------------------------
<values>Enterprisedb</values>
<values>Wipro</values>
<values>Infosys<place>Bangalore</place></values>
(3 rows)
Some of the xml related links:
---
Regards,
Raghavendra
EnterpriseDB Corporation