Compiere 3.1

org.compiere.db
Class DBUtils

java.lang.Object
  extended by org.compiere.db.DBUtils

public class DBUtils
extends Object

Database Utilities

Version:
$Id$
Author:
Jinglun Zhang a few common functions, some merged from existing classes so that we do not need to maintain multiple copies

Constructor Summary
DBUtils()
           
 
Method Summary
static void main(String[] args)
           
static String nullValue(String sqlClause, int dataType)
          Get a string representation of literal used in SQL clause
static String repRownum(String oraS)
          jz rewrite SQL if there is ROWNUM=1 in a query with updated in select max(updated) from ...
static String TO_CHAR(String columnName, int displayType, String AD_Language)
          Use user defined SQL functions for formatted Date, Number
static String TO_DATE(Timestamp time, boolean dayOnly)
          Create SQL TO Date String from Timestamp
static String TO_NUMBER(BigDecimal number, int displayType)
          Return number as string for INSERT statements with correct precision
static String updateSetSelectList(String sql)
          jz NOT a generic one change update set (...) = (select ... from ) standard format
static String whereSelectList(String sql)
          jz: NOT a generic one change WHERE (...)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DBUtils

public DBUtils()
Method Detail

repRownum

public static String repRownum(String oraS)
jz rewrite SQL if there is ROWNUM=1 in a query with updated in select max(updated) from ... this is not a generic solution, with assume: 1. only ROWNUM=1 2. it is in a query with 1 table and the table has a column called "UPDATED" 3. key words in upper case

Parameters:
oraS - oracle style statement
Returns:
statement

TO_DATE

public static String TO_DATE(Timestamp time,
                             boolean dayOnly)
Create SQL TO Date String from Timestamp

Parameters:
time - Date to be converted
dayOnly - true if time set to 00:00:00
Returns:
date function

TO_CHAR

public static String TO_CHAR(String columnName,
                             int displayType,
                             String AD_Language)
Use user defined SQL functions for formatted Date, Number

Parameters:
columnName - the column name in the SQL
displayType - Display Type
AD_Language - 6 character language setting (from Env.LANG_*)
Returns:
TRIM(TO_CHAR(columnName,'9G999G990D00','NLS_NUMERIC_CHARACTERS='',.''')) or TRIM(TO_CHAR(columnName,'TM9')) depending on DisplayType and Language
See Also:
DisplayType, Env

nullValue

public static String nullValue(String sqlClause,
                               int dataType)
Get a string representation of literal used in SQL clause

Parameters:
sqlClause - "S", "U","I", "W"
dataType - java.sql.Types
Returns:
db2: nullif(x,x)

TO_NUMBER

public static String TO_NUMBER(BigDecimal number,
                               int displayType)
Return number as string for INSERT statements with correct precision

Parameters:
number - number
displayType - display Type
Returns:
number as string

whereSelectList

public static String whereSelectList(String sql)
jz: NOT a generic one change WHERE (...) IN/NOT IN (select ... from ) to one column at a time Warning: This may not translate an equivalent sql

Parameters:
sql - update clause
Returns:
new sql

updateSetSelectList

public static String updateSetSelectList(String sql)
jz NOT a generic one change update set (...) = (select ... from ) standard format

Parameters:
sql - update clause
Returns:
new sql

main

public static void main(String[] args)
Parameters:
args -

Compiere 3.1

Compiere® is a registered trademark of ComPiere, Inc. ©2004-2008 HumanFlash.com All rights reserved.