本文整理汇总了Java中org.pentaho.di.core.database.DatabaseMeta.requiresCastToVariousForIsNull方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseMeta.requiresCastToVariousForIsNull方法的具体用法?Java DatabaseMeta.requiresCastToVariousForIsNull怎么用?Java DatabaseMeta.requiresCastToVariousForIsNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.core.database.DatabaseMeta
的用法示例。
在下文中一共展示了DatabaseMeta.requiresCastToVariousForIsNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setLookup
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public void setLookup(RowMetaInterface rowMeta) throws KettleDatabaseException
{
data.lookupParameterRowMeta = new RowMeta();
data.lookupReturnRowMeta = new RowMeta();
DatabaseMeta databaseMeta = meta.getDatabaseMeta();
String sql = "SELECT ";
for (int i = 0; i < meta.getUpdateLookup().length; i++)
{
if (i != 0) sql += ", ";
sql += databaseMeta.quoteField(meta.getUpdateLookup()[i]);
data.lookupReturnRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getUpdateStream()[i]).clone() );
}
sql += " FROM " + data.schemaTable + " WHERE ";
for (int i = 0; i < meta.getKeyLookup().length; i++)
{
if (i != 0){
sql += " AND ";
}
sql += " ( ( ";
sql += databaseMeta.quoteField(meta.getKeyLookup()[i]);
if ("BETWEEN".equalsIgnoreCase(meta.getKeyCondition()[i]))
{
sql += " BETWEEN ? AND ? ";
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream2()[i]) );
}
else
{
if ("IS NULL".equalsIgnoreCase(meta.getKeyCondition()[i]) || "IS NOT NULL".equalsIgnoreCase(meta.getKeyCondition()[i]))
{
sql += " " + meta.getKeyCondition()[i] + " ";
}
else if ("= ~NULL".equalsIgnoreCase(meta.getKeyCondition()[i])){
sql += " IS NULL AND ";
if (databaseMeta.requiresCastToVariousForIsNull()) {
sql += " CAST(? AS VARCHAR(256)) IS NULL ";
}
else{
sql += " ? IS NULL ";
}
// null check
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
sql += " ) OR ( "+ databaseMeta.quoteField(meta.getKeyLookup()[i])+" = ? ";
// equality check, cloning so auto-rename because of adding same fieldname does not cause problems
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]).clone() );
}
else
{
sql += " " + meta.getKeyCondition()[i] + " ? ";
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
}
}
sql += " ) ) ";
}
try
{
if(log.isDetailed()) logDetailed("Setting preparedStatement to [" + sql + "]");
data.prepStatementLookup = data.db.getConnection().prepareStatement(databaseMeta.stripCR(sql));
}
catch (SQLException ex)
{
throw new KettleDatabaseException("Unable to prepare statement for SQL statement [" + sql + "]", ex);
}
}
示例2: prepareUpdate
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public void prepareUpdate(RowMetaInterface rowMeta) throws KettleDatabaseException
{
DatabaseMeta databaseMeta = meta.getDatabaseMeta();
data.updateParameterRowMeta = new RowMeta();
String sql = "UPDATE " + data.schemaTable + Const.CR;
sql += "SET ";
boolean comma=false;
for (int i=0;i<meta.getUpdateLookup().length;i++)
{
if ( meta.getUpdate()[i].booleanValue() ) {
if (comma) sql+= ", ";
else comma=true;
sql += databaseMeta.quoteField(meta.getUpdateLookup()[i]);
sql += " = ?" + Const.CR;
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getUpdateStream()[i]).clone() );
}
}
sql += "WHERE ";
for (int i=0;i<meta.getKeyLookup().length;i++)
{
if (i!=0) sql += "AND ";
sql += " ( ( ";
sql += databaseMeta.quoteField(meta.getKeyLookup()[i]);
if ("BETWEEN".equalsIgnoreCase(meta.getKeyCondition()[i]))
{
sql += " BETWEEN ? AND ? ";
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream2()[i]) );
}
else
if ("IS NULL".equalsIgnoreCase(meta.getKeyCondition()[i]) || "IS NOT NULL".equalsIgnoreCase(meta.getKeyCondition()[i]))
{
sql += " "+meta.getKeyCondition()[i]+" ";
}
else if ("= ~NULL".equalsIgnoreCase(meta.getKeyCondition()[i])){
sql += " IS NULL AND ";
if (databaseMeta.requiresCastToVariousForIsNull()) {
sql += "CAST(? AS VARCHAR(256)) IS NULL";
}
else{
sql += "? IS NULL";
}
// null check
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
sql += " ) OR ( "+ databaseMeta.quoteField(meta.getKeyLookup()[i])+" = ?";
// equality check, cloning so auto-rename because of adding same fieldname does not cause problems
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]).clone() );
}
else
{
sql += " "+meta.getKeyCondition()[i]+" ? ";
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]).clone() );
}
sql += " ) ) ";
}
try
{
if(log.isDetailed()) logDetailed("Setting update preparedStatement to ["+sql+"]");
data.prepStatementUpdate=data.db.getConnection().prepareStatement(databaseMeta.stripCR(sql));
}
catch(SQLException ex)
{
throw new KettleDatabaseException("Unable to prepare statement for SQL statement [" + sql + "]", ex);
}
}
示例3: setLookup
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public void setLookup(RowMetaInterface rowMeta) throws KettleDatabaseException
{
data.lookupParameterRowMeta = new RowMeta();
data.lookupReturnRowMeta = new RowMeta();
DatabaseMeta databaseMeta = meta.getDatabaseMeta();
String sql = "SELECT ";
for (int i = 0; i < meta.getUpdateLookup().length; i++)
{
if (i != 0) sql += ", ";
sql += databaseMeta.quoteField(meta.getUpdateLookup()[i]);
data.lookupReturnRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getUpdateStream()[i]) );
}
sql += " FROM " + data.schemaTable + " WHERE ";
for (int i = 0; i < meta.getKeyLookup().length; i++)
{
if (i != 0){
sql += " AND ";
}
sql += " ( ( ";
sql += databaseMeta.quoteField(meta.getKeyLookup()[i]);
if ("BETWEEN".equalsIgnoreCase(meta.getKeyCondition()[i]))
{
sql += " BETWEEN ? AND ? ";
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream2()[i]) );
}
else
{
if ("IS NULL".equalsIgnoreCase(meta.getKeyCondition()[i]) || "IS NOT NULL".equalsIgnoreCase(meta.getKeyCondition()[i]))
{
sql += " " + meta.getKeyCondition()[i] + " ";
}
else if ("= ~NULL".equalsIgnoreCase(meta.getKeyCondition()[i])){
sql += " IS NULL AND ";
if (databaseMeta.requiresCastToVariousForIsNull()) {
sql += "CAST(? AS VARCHAR(256)) IS NULL";
}
else{
sql += "? IS NULL";
}
// null check
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
sql += " ) OR ( "+ databaseMeta.quoteField(meta.getKeyLookup()[i])+" = ?";
// equality check, cloning so auto-rename because of adding same fieldname does not cause problems
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]).clone() );
}
else
{
sql += " " + meta.getKeyCondition()[i] + " ? ";
data.lookupParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
}
}
sql += " ) ) ";
}
try
{
if(log.isDetailed()) logDetailed("Setting preparedStatement to [" + sql + "]");
data.prepStatementLookup = data.db.getConnection().prepareStatement(databaseMeta.stripCR(sql));
}
catch (SQLException ex)
{
throw new KettleDatabaseException("Unable to prepare statement for SQL statement [" + sql + "]", ex);
}
}
示例4: prepareUpdate
import org.pentaho.di.core.database.DatabaseMeta; //导入方法依赖的package包/类
public void prepareUpdate(RowMetaInterface rowMeta) throws KettleDatabaseException
{
DatabaseMeta databaseMeta = meta.getDatabaseMeta();
data.updateParameterRowMeta = new RowMeta();
String sql = "UPDATE " + data.schemaTable + Const.CR;
sql += "SET ";
for (int i=0;i<meta.getUpdateLookup().length;i++)
{
if (i!=0) sql+= ", ";
sql += databaseMeta.quoteField(meta.getUpdateLookup()[i]);
sql += " = ?" + Const.CR;
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getUpdateStream()[i]) );
}
sql += "WHERE ";
for (int i=0;i<meta.getKeyLookup().length;i++)
{
if (i!=0) sql += "AND ";
sql += " ( ( ";
sql += databaseMeta.quoteField(meta.getKeyLookup()[i]);
if ("BETWEEN".equalsIgnoreCase(meta.getKeyCondition()[i]))
{
sql += " BETWEEN ? AND ? ";
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream2()[i]) );
}
else if ("IS NULL".equalsIgnoreCase(meta.getKeyCondition()[i]) || "IS NOT NULL".equalsIgnoreCase(meta.getKeyCondition()[i]))
{
sql += " "+meta.getKeyCondition()[i]+" ";
}
else if ("= ~NULL".equalsIgnoreCase(meta.getKeyCondition()[i])){
sql += " IS NULL AND ";
if (databaseMeta.requiresCastToVariousForIsNull()) {
sql += "CAST(? AS VARCHAR(256)) IS NULL";
}
else{
sql += "? IS NULL";
}
// null check
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
sql += " ) OR ( "+ databaseMeta.quoteField(meta.getKeyLookup()[i])+" = ?";
// equality check, cloning so auto-rename because of adding same fieldname does not cause problems
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]).clone() );
}
else
{
sql += " "+meta.getKeyCondition()[i]+" ? ";
data.updateParameterRowMeta.addValueMeta( rowMeta.searchValueMeta(meta.getKeyStream()[i]) );
}
sql += " ) ) ";
}
try
{
if(log.isDetailed()) logDetailed("Setting update preparedStatement to ["+sql+"]");
data.prepStatementUpdate=data.db.getConnection().prepareStatement(databaseMeta.stripCR(sql));
}
catch(SQLException ex)
{
throw new KettleDatabaseException("Unable to prepare statement for SQL statement [" + sql + "]", ex);
}
}