Tuesday, May 15, 2007

Extract CSV file format in Oracle SQL

How to extract CSV file format data in Oracle SQL Plus.

---10G Solution. On SQL Plus session
alter session set nls_date_format='YYYY-MM-DD';

Session altered.

select regexp_replace(column_value,' *<[^>]*>[^>]*>’,';’)
from table(xmlsequence(cursor(select * from emp)));

=======================

-- Oracle 9i Solution. SQL Plus session.
-- Following sql fail to give EMPTY space for NULL values properly.
-- See PL/SQL solution to handle
SELECT XMLTRANSFORM
(COLUMN_VALUE,
XMLTYPE
('















'
)
) csv
FROM TABLE (XMLSEQUENCE (CURSOR (SELECT *
FROM emp)))
/
=======================================
---- Oracle 9i PL/SQL solution
SQL> VAR cur refcursor

SQL> DECLARE
ctx DBMS_XMLGEN.ctxhandle;
BEGIN
ctx := DBMS_XMLGEN.newcontext ('select * from emp');
DBMS_XMLGEN.setnullhandling (ctx, DBMS_XMLGEN.empty_tag);

OPEN :cur FOR
SELECT (SELECT RTRIM(XMLAGG (XMLELEMENT (c,VALUE (t2),',').EXTRACT('//text()')),',')
FROM TABLE (XMLSEQUENCE (VALUE (t1).EXTRACT ('ROW/*'))) t2) csv
FROM TABLE(XMLSEQUENCE(DBMS_XMLGEN.getxmltype (ctx).EXTRACT('ROWSET/ROW'))) t1;

DBMS_XMLGEN.closecontext(ctx);
END;
/
PL/SQL procedure successfully completed.

SQL> PRINT cur
==================================

New Articles to Read - Java

XML Parser Benchmarks: Part 1

JavaOne 2007, #2: Making Web Apps Easy
Summary
Today, JavaOne 2007 showcased a complete open source technology stack that lets you develop and deploy web applications quickly and easily, including JRuby, Rails, NetBeans, and Glassfish

Integrating Struts With Spring


Hibernate Interceptors - An Introduction


New Articles to Read - Java

XML Parser Benchmarks: Part 1

JavaOne 2007, #2: Making Web Apps Easy
   Summary
Today, JavaOne 2007 showcased a complete open source technology stack that lets you develop and deploy web applications quickly and easily, including JRuby, Rails, NetBeans, and Glassfish

Integrating Struts With Spring


Hibernate Interceptors - An Introduction


Sunday, May 06, 2007

A Primer on Spring's Data Access Object (DAO) Framework

A Primer on Spring's Data Access Object (DAO) Framework by Dhrubojyoti Kayal -- This article introduces the Spring Data Access Object (DAO) framework. After examining the architectural needs for DAO, it describes the DAO pattern in general and how Spring simplifies the implementation.

Thursday, May 03, 2007

Collection of JVM Options

I found link about Collection of JVM options compiled by Joseph D. Mocker (Sun Microsystems, Inc.)

Apache Axis2 - Nice Technical Articles

Today, I was looking at Jroller.com and found nice entry posted by Glen Mazza. Mazza posted Axis2 - Technical Articles. It is very good collection of articles about Apache Axis2. From his posting, I was directed to ws02.org site. This where I finally read Axis2 technical articles.

WSO2.org is Oxygen for Web Service Developers. It has got very nice detail articles and tutorials for Web Services projects related to Apache Open Source.

Thanks to Glen Mazza for his posting.