Package org.compiere.dbPort
Class Convert
java.lang.Object
org.compiere.dbPort.Convert
- Direct Known Subclasses:
Convert_Oracle
,Convert_SQL92
Convert SQL from Oracle syntax to Target DB syntax
- Version:
- $Id: Convert.java,v 1.3 2006/07/30 00:55:04 jjanke Exp $
- Author:
- Jorg Janke, Victor Perez, Teo Sarca, www.arhipac.ro
- BF [ 2782095 ] Do not log *Access records https://sourceforge.net/p/adempiere/bugs/1867/
- TODO: BF [ 2782611 ] Migration scripts are not UTF8 https://sourceforge.net/p/adempiere/bugs/1869/, Teo Sarca
- BF [ 3137355 ] PG query not valid when contains quotes and backslashes https://sourceforge.net/p/adempiere/bugs/2560/
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
cleanUpStatement
(String statement) Clean up Statement.static void
Close the files for migration scripts, used just on TestsString[]
Convert SQL Statements (stops at first error).
If an error occurred, hadError() returns true.convertAll
(String sqlStatements) Convert SQL Statements (stops at first error).protected String[]
Conversion routine (stops at first error).convertStatement
(String sqlStatement) Convert single Statementsprotected String
convertWithConvertMap
(String sqlStatement) do convert map base conversionprotected String
hook for database specific escape of quoted string ( if needed )boolean
execute
(String sqlStatements, Connection conn) Execute SQL Statements (stops at first error).Return last conversion error or null.Get convert map for use in sql convertionReturn last execution exceptionstatic String
Get the name of the migration script filestatic String
getMigrationScriptFileName
(String ticketComment) static String
getMigrationScriptFolder
(String dbtype) boolean
hasError()
Returns true if a conversion or execution error had occurred.static boolean
isDontLogTable
(String tableName) static boolean
abstract boolean
isOracle()
True if the database support native oracle dialect, false otherwise.static void
logMigrationScript
(String oraStatement, String pgStatement) Log oraStatement and pgStatement to SQL migration script file.protected String
recoverQuotedStrings
(String retValue, Vector<String> retVars, String nonce) Utility method to recover quoted string store in retVarsprotected String
replaceQuotedStrings
(String inputValue, Vector<String> retVars, String nonce) Utility method to replace quoted string with a predefined marker.void
setVerbose
(boolean verbose) Set Verbose
-
Field Details
-
REGEX_FLAGS
public static final int REGEX_FLAGSRegEx: insensitive and dot to include line end characters- See Also:
-
m_stmt
Statement used -
m_conversionError
Last Conversion Error -
m_exception
Last Execution Error -
m_verbose
protected boolean m_verboseVerbose Messages
-
-
Constructor Details
-
Convert
public Convert()
-
-
Method Details
-
setVerbose
public void setVerbose(boolean verbose) Set Verbose- Parameters:
verbose
-
-
execute
Execute SQL Statements (stops at first error).
If an error occur, hadError() returns true.
You can get error details via getConversionError() or getException().- Parameters:
sqlStatements
-conn
- connection- Returns:
- true if success
- Throws:
IllegalStateException
- if no connection
-
getException
Return last execution exception- Returns:
- execution exception
-
hasError
public boolean hasError()Returns true if a conversion or execution error had occurred. Get more details via getConversionError() or getException().- Returns:
- true if error had occurred
-
convertAll
Convert SQL Statements (stops at first error).
Statements are delimited by /.
If an error occurred, hadError() returns true. You can get details via getConversionError().- Parameters:
sqlStatements
-- Returns:
- converted statement as a string
-
convert
Convert SQL Statements (stops at first error).
If an error occurred, hadError() returns true. You can get details via getConversionError().- Parameters:
sqlStatements
-- Returns:
- Array of converted Statements
-
getConversionError
Return last conversion error or null.- Returns:
- last conversion error
-
convertIt
Conversion routine (stops at first error).- convertStatement - convertWithConvertMap - convertComplexStatement - decode, sequence, exception
- Parameters:
sqlStatements
-- Returns:
- array of converted statements
-
cleanUpStatement
Clean up Statement. Remove trailing spaces, carriage return and tab- Parameters:
statement
-- Returns:
- sql statement
-
replaceQuotedStrings
Utility method to replace quoted string with a predefined marker.- Parameters:
inputValue
-retVars
-nonce
-- Returns:
- string
-
recoverQuotedStrings
Utility method to recover quoted string store in retVars- Parameters:
retValue
-retVars
-nonce
-- Returns:
- string
-
escapeQuotedString
hook for database specific escape of quoted string ( if needed )- Parameters:
in
-- Returns:
- string
-
convertWithConvertMap
do convert map base conversion- Parameters:
sqlStatement
-- Returns:
- converted sql statement
-
getConvertMap
Get convert map for use in sql convertion- Returns:
- map
-
convertStatement
Convert single Statements. - remove comments - process FUNCTION/TRIGGER/PROCEDURE - process Statement- Parameters:
sqlStatement
-- Returns:
- converted statement
-
isOracle
public abstract boolean isOracle()True if the database support native oracle dialect, false otherwise.- Returns:
- boolean
-
logMigrationScript
Log oraStatement and pgStatement to SQL migration script file.- Parameters:
oraStatement
-pgStatement
-
-
getMigrationScriptFileName
- Parameters:
ticketComment
-- Returns:
- migration script file name
-
getMigrationScriptFolder
- Parameters:
dbtype
- oracle or postgresql- Returns:
- absolute migration script folder path for dbtype
-
isLogMigrationScript
public static boolean isLogMigrationScript()- Returns:
- true if it is in log migration script mode
-
isDontLogTable
- Parameters:
tableName
-- Returns:
- true if log migration script should ignore tableName
-
closeLogMigrationScript
public static void closeLogMigrationScript()Close the files for migration scripts, used just on Tests -
getGeneratedMigrationScriptFileName
Get the name of the migration script file- Returns:
-