use of org.datanucleus.store.rdbms.sql.SQLText in project datanucleus-rdbms by datanucleus.
the class SybaseAdapter method getUpdateTableStatement.
/**
* Method to return the SQLText for an UPDATE TABLE statement.
* Returns the SQLText for <code>UPDATE T1 SET x1 = val1, x2 = val2 FROM MYTBL T1</code>.
* Override if the datastore doesn't support that standard syntax.
* @param tbl The primary table
* @param setSQL The SQLText for the SET component
* @return SQLText for the update statement
*/
public SQLText getUpdateTableStatement(SQLTable tbl, SQLText setSQL) {
// "UPDATE T1"
SQLText sql = new SQLText("UPDATE ").append(tbl.getAlias().toString());
// " SET x1 = val1, x2 = val2"
sql.append(" ").append(setSQL);
// " FROM MYTBL T1"
sql.append(" FROM ").append(tbl.toString());
return sql;
}
use of org.datanucleus.store.rdbms.sql.SQLText in project datanucleus-rdbms by datanucleus.
the class BaseDatastoreAdapter method getUpdateTableStatement.
/**
* Method to return the SQLText for an UPDATE TABLE statement.
* Returns the SQLText for <code>UPDATE tbl t1 SET x1 = val1, x2 = val2</code>.
* Override if the datastore doesn't support that standard syntax.
* @param tbl The primary table
* @param setSQL The SQLText for the SET component
* @return SQLText for the update statement
*/
public SQLText getUpdateTableStatement(SQLTable tbl, SQLText setSQL) {
SQLText sql = new SQLText("UPDATE ");
// "MYTBL T1"
sql.append(tbl.toString());
sql.append(" ").append(setSQL);
return sql;
}
use of org.datanucleus.store.rdbms.sql.SQLText in project datanucleus-rdbms by datanucleus.
the class StringTrim3Method method getExpression.
/* (non-Javadoc)
* @see org.datanucleus.store.rdbms.sql.method.SQLMethod#getExpression(org.datanucleus.store.rdbms.sql.expression.SQLExpression, java.util.List)
*/
public SQLExpression getExpression(SQLStatement stmt, SQLExpression expr, List<SQLExpression> args) {
if (args != null && args.size() > 1) {
throw new NucleusException("TRIM has incorrect number of args");
}
// {stringExpr}.trim(trimChar)
SQLExpression trimCharExpr = null;
if (args != null && args.size() > 0) {
trimCharExpr = args.get(0);
}
List trimArgs = new ArrayList();
if (trimCharExpr == null) {
trimArgs.add(expr);
} else {
StringExpression argExpr = new StringExpression(stmt, expr.getJavaTypeMapping(), "NULL", null);
SQLText sql = argExpr.toSQLText();
sql.clearStatement();
sql.append(getTrimSpecKeyword() + " ");
sql.append(trimCharExpr);
sql.append(" FROM ");
sql.append(expr);
trimArgs.add(argExpr);
}
StringExpression trimExpr = new StringExpression(stmt, expr.getJavaTypeMapping(), "TRIM", trimArgs);
return trimExpr;
}
use of org.datanucleus.store.rdbms.sql.SQLText in project datanucleus-rdbms by datanucleus.
the class SQLiteAdapter method getUpdateTableStatement.
/**
* Method to return the SQLText for an UPDATE TABLE statement.
* Returns the SQLText for <code>UPDATE SCH1.TBL1 SET x1 = val1, x2 = val2</code> since SQLite doesn't allow any aliases in UPDATEs.
* @param tbl The primary table
* @param setSQL The SQLText for the SET component
* @return SQLText for the update statement
*/
public SQLText getUpdateTableStatement(SQLTable tbl, SQLText setSQL) {
// "UPDATE SCH1.TBL1"
SQLText sql = new SQLText("UPDATE ").append(tbl.getTable().toString());
// " SET x1 = val1, x2 = val2"
sql.append(" ").append(setSQL);
return sql;
}
Aggregations