Sunday, October 23, 2005

XML (XMLType) inside PL/SQL Oracle 9/10

The XMLType is an OO XML aware data type. It can be used in columns or in PL/SQL just like VARCHAR2 or DATE. XMLType has member functions that allow access to data using XPath.

A quick example extracting a specific value from an XML varchar2 string:
DECLARE
v VARCHAR2(32000) := 'ABC';
x XMLType;
BEGIN
x := XMLType(v);
DBMS_OUTPUT.put_line(
x.extract('/DATA/LINE[1]').getStringVal()
);
DBMS_OUTPUT.put_line(
x.extract('/DATA/LINE[1]/text()').getStringVal()
);
END;

2 comments:

Jozef Ciuraj said...

Pay per click advertising. Best solution for targeted website traffic. Getting wholesale web traffic and bidding on PPC keywords. Maximize and manage your ROI with our bid cap calculator.

Visit Fairbiz.biz Mega Mall. We have what you are looking for.

Mobeen said...

Good to see OO XML type integrated in Oracle, there must be some equivalent of this in upcoming Yukon