Mega Code Archive

 
Categories / Oracle PLSQL / XML
 

Create xml attribute with xmlattribute function

SQL> CREATE TABLE products(   2    product_id              NUMBER(6),   3    name            VARCHAR2(50),   4    category        VARCHAR2(50),   5    price      NUMBER(8,2),   6    min_price       NUMBER(8,2)   7  ); Table created. SQL> SQL> select xmlelement( "Product",xmlattributes(p.product_id,p.name as "Name"),xmlforest(p.category as "Category",p.price as "price"))   2  from products p; no rows selected SQL> SQL> drop table products; Table dropped. SQL> SQL>