com.agimatec.sql
Class SQLStringGenerator
java.lang.Object
com.agimatec.sql.SQLClauseParserAbstract
com.agimatec.sql.SQLStringGenerator
public class SQLStringGenerator
- extends SQLClauseParserAbstract
Generates an SQL String (with parameters) from the given SQL-statement (containing parameter markers)
and a given parameter array.
Also handles string constants correctly.
Caution: Uses Oracle Date String format!
$Author: stumm $
| Methods inherited from class com.agimatec.sql.SQLClauseParserAbstract |
addParseExpression, foundParamExpression, foundParamOpenBracket, getResultWriter, handleExpression, initForParse, isParamExpressionTerminator, parse, signalMissingToken, signalUnexpectedToken, skip |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
params
protected final List params
paramIdx
protected int paramIdx
SQLStringGenerator
public SQLStringGenerator(String input,
Writer output,
List aParams)
- Parameters:
input - e.g. SELECT * FROM TABLE WHERE OID = ? AND THEDATE = ?output - a writer for the resultaParams - e.g. a List containing a String for OID and a Date for THEDATE.
output contains the following after the parse() methods has been executed:
SELECT * FROM TABLE WHERE OID = 'oidvalue' AND THEDATE = to_date('datevalue', 'YYYY-MM-DD')
addParseParamExpression
protected void addParseParamExpression(String aString)
- Add the parameter identified by aString to the result.
- Specified by:
addParseParamExpression in class SQLClauseParserAbstract
addParseParamBracket
protected void addParseParamBracket(String aString)
- Specified by:
addParseParamBracket in class SQLClauseParserAbstract
foundParamMarker
protected void foundParamMarker()
throws IOException
- Parameter marker found at current position.
Parse the parameter expression.
- Overrides:
foundParamMarker in class SQLClauseParserAbstract
- Throws:
IOException
handleParam
protected void handleParam(Object aValue)
throws IOException
- Throws:
IOException
toSQLParamString
protected String toSQLParamString(Object value)
appendSQLParamString
public void appendSQLParamString(StringBuilder buf,
Object value)
asProcedureCall
public static String asProcedureCall(String sql)
- convert the sql to be a valid PL/SQL Stored Procudure call.
Oracle expects different SQL than the JDBC standard.
JDBC Standard: "call "
Oracle: "begin ;end;"
- Parameters:
sql -
- Returns:
- the sql decorated to be a valid procedure call.
Copyright © 2008-2012. All Rights Reserved.