[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: Unions in SQR Select Statements



We are successfully using this approach to join related audit records to
determine any change, selecting only the distinct key.  The actuals select
contains as many as 8 unions.  Good luck.

begin-select on-error=SQL-Error
DISTINCT PROJECT_ID &project_id
   add 1 to #input_rec_cnt
   do Output-Process
from ps_PROJ_AUD_VW a
   where a.AUDIT_STAMP >= to_date(&last_updt_dttm,'yyyymmddhh24miss') and
         a.AUDIT_STAMP <= to_date(&proctime,'yyyymmddhh24miss')
union
   select DISTINCT PROJECT_ID
   from ps_PRJDT_AUD_V c
   where c.AUDIT_STAMP >= to_date(&last_updt_dttm,'yyyymmddhh24miss') and
         c.AUDIT_STAMP <= to_date(&proctime,'yyyymmddhh24miss')

end-select

end-procedure ! Scan-Audit





        -----Original Message-----
        From:   John Munkberg (Connexus) [SMTP:Johnm@connexusenergy.com]
        Sent:   Tuesday, October 27, 1998 2:19 PM
        To:     Multiple recipients of list SQR-USERS
        Subject:        Unions in SQR Select Statements

        Is is possible to use UNIONS in SQR?   (Oracle 7.3 DB)

        I want to do something like this (forgive the syntax, that's my
        question):

        BEGIN-SELECT
        empno
          DO results
          from employee
          UNION
        empno
          DO results
          from supervisors
        END-SELECT

        I would then feed each distinct empno into another procedure (results)
        to collect data and print the results.

        I know I could create a view from which to select all the empnos, but
        then there is maintenance, etc.



        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ~~~~~~~~~
        |   John E. Munkberg    |   CONNEXUS  ENERGY   |
        JohnM@CONNEXUSENERGY.com     |
        |     612.323.2782      |      Ramsey, MN     |
        http://WWW.CONNEXUSENERGY.com  |
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        ~~~~~~~~~