db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Wa (JIRA)" <j...@apache.org>
Subject [jira] [Created] (TORQUE-322) Support for SQL Set Operations (UNION, INTERSECT, ...)
Date Wed, 30 Jul 2014 07:45:38 GMT
Michael Wa created TORQUE-322:
---------------------------------

             Summary: Support for SQL Set Operations (UNION, INTERSECT, ...)
                 Key: TORQUE-322
                 URL: https://issues.apache.org/jira/browse/TORQUE-322
             Project: Torque
          Issue Type: New Feature
    Affects Versions: 4.0
            Reporter: Michael Wa


* It would be nice to support sql constructs like:
SELECT * FROM sales2005 UNION SELECT * FROM sales2006;

* If you want to realize the UNION operator you have to do something like that:

[...]
Criteria criteriaA = new Criteria();
criteriaA.where( ... );
criteriaA.addSelectColumn(COLUMNX);

Query queryA = SqlBuilder.buildQuery(criteriaA);
String sqlA = queryA.toString();
List<Object> replacementsA = queryA.getPreparedStatementReplacements();

Criteria criteriaB = new Criteria();
criteriaB.where( ... );
criteriaB.addSelectColumn(...);

Query queryB = SqlBuilder.buildQuery(criteriaB);
String sqlB = queryB.toString();
List<Object> replacementsB = queryB.getPreparedStatementReplacements();

List<Object> replacements = Lists.newArrayList();
replacements.addAll(replacementsA);
replacements.addAll(replacementsB);

String sql = COLUMNX + " IN (" + sqlA + " UNION " + sqlB + ")";

mainCriteria.whereVerbatimSql(sql, replacements.toArray());
[...] 





--
This message was sent by Atlassian JIRA
(v6.2#6252)

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message