Sunday, 21 July 2013

Rip SQL into and out of Java

Advanced parameters: to rip sql in and out of say java using Output type, Enclosed In, Escaped By. so:

SQL.append("SELECT 1 FROM dual"); 

 -> make a change ->

(all one line)
SQL.append("SELECT 1,xxxxxxxxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxxxxxxxxxxxxxxxxxxx,xxxxxxxx FROM dual"); 
-> go to right click advanced format output as StringBuffer with:
 enclosed in " 
escaped by \ 

SQL.append("SELECT \n");
SQL.append(" 1 , xxxxxxxxxxxxxxxxxxxxxxxxxxxxx , xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \n");
SQL.append(" , xxxxxxxxxxxxxxxxxxxxxxxxx , xxxxxxxx \n");
SQL.append("FROM \n");
SQL.append(" dual");

i.e. it rips out the SQL (removing \n), formats it (core formatter into SQL)  then puts in the SQL.append (" at the start of the line and \n"); at the end of the line "); at the end of the last line.

What can go wrong? Fancy java. Should work but less tested for vb/sql in sql/php ...

What I should fix? Advanced formatter settings are not remembered between right clicks.

No comments: