Posts

Showing posts from October, 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;