Author Topic: OnDemand create a UNION based SQL  (Read 2699 times)

jfunk

  • Guest
OnDemand create a UNION based SQL
« on: December 05, 2013, 10:19:01 AM »
Greetings,

Can OnDemand create a UNION based SQL for:

SELECT COL1, COL2, INDEX1, INDEX2
  FROM TBLA
 WHERE INDEX1 = ?
       OR INDEX2 = ?
 FETCH FIRST 100 ROWS ONLY;

Provided INDEX1 and INDEX2 are the table's index, this is either an index nullification or a multi-index scan.  In either case this is not a good situation.  It is probably more preferable to have the SQL written as:

SELECT COL1, COL2, INDEX1, INDEX2
  FROM TBLA
 WHERE INDEX1 = ?
 UNION
SELECT COL1, COL2, INDEX1, INDEX2
  FROM TBLA
 WHERE INDEX2 = ?
 FETCH FIRST 100 ROWS ONLY;

I know you can build SQL using the keyboard with this in it.  Is this the only way?  If not, please describe how using the Build SQL option to do this.  Thank you.