Class Convert_SQL92

  • Direct Known Subclasses:
    Convert_PostgreSQL

    public abstract class Convert_SQL92
    extends Convert
    Convert from oracle syntax to sql 92 standard
    Author:
    Low Heng Sin
    • Constructor Detail

      • Convert_SQL92

        public Convert_SQL92()
    • Method Detail

      • convertOuterJoin

        protected String convertOuterJoin​(String sqlStatement)
        Convert Outer Join. Converting joins can ve very complex when multiple tables/keys are involved. The main scenarios supported are two tables with multiple key columns and multiple tables with single key columns.
        
              SELECT a.Col1, b.Col2 FROM tableA a, tableB b WHERE a.ID=b.ID(+)
              => SELECT a.Col1, b.Col2 FROM tableA a LEFT OUTER JOIN tableB b ON (a.ID=b.ID)
        
              SELECT a.Col1, b.Col2 FROM tableA a, tableB b WHERE a.ID(+)=b.ID
              => SELECT a.Col1, b.Col2 FROM tableA a RIGHT OUTER JOIN tableB b ON (a.ID=b.ID)
          Assumptions:
          - No outer joins in sub queries (ignores sub-queries)
          - OR condition ignored (not sure what to do, should not happen)
          Limitations:
          - Parameters for outer joins must be first - as sequence of parameters changes
          
        Parameters:
        sqlStatement -
        Returns:
        converted statement
      • convertDecode

        protected String convertDecode​(String sqlStatement,
                                       int fromIndex)
        Converts Decode.
        
              DECODE (a, 1, 'one', 2, 'two', 'none')
               => CASE WHEN a = 1 THEN 'one' WHEN a = 2 THEN 'two' ELSE 'none' END
          
        Parameters:
        sqlStatement -
        Returns:
        converted statement
      • convertDelete

        protected String convertDelete​(String sqlStatement)
        Converts Delete.
                DELETE C_Order i WHERE  
                 => DELETE FROM C_Order WHERE  
         
        Parameters:
        sqlStatement -
        Returns:
        converted statement
      • isOperator

        protected boolean isOperator​(char c)
        Is character a valid sql operator
        Parameters:
        c -
        Returns:
        boolean