# Coalescing Without Duplicates

This section presents actual Oracle source lines which combine records with adjacent and/or overlapping periods into single periods covering the entire duration for which the adjacent/overlapping periods were valid. The following techniques are presented :

1. Iterative SQL - Uses SQL statements in a loop. Not as efficient as the cursor-based but competes when indexed.
   - Oracle SQLPLUS code (Iterative.SQL)
   - Result (Iterative.result)
2. Pure SQL - Uses *ONLY* SQL Statements. From performance measures taken on larger tables, seems to be slower than iterative or cursor-based strategies. Being in pure SQL, this approach is the most portable.
   - Oracle SQLPLUS code (PureSQL.SQL)
   - Result (PureSQL.result)
3. CursorBased - Uses cursors to go through every record, comparing period boundaries. Garnered the best results from the performance experiments made. Problem with this approach, though, is that it is not SQL at all and relies on a programming language extension for SQL from Oracle (PLSQL).
   - Oracle SQLPLUS code (CursorBased.SQL)
   - Result (CursorBased.result)

Note : All Source files, include code to populate sample tables which would be coalesced. The result files, contains the results of the experiment.

/jag