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

sql statement - Why no work???



Hi all,

My code is below.  Apparently it is finding no rows, because
  move 'Y' to $Found
  do Get-First-Work-State
are never executed.  However, when I chop the sql out of
sqr and put it into sqlplus with literals instead of vars
it returns the correct row.

So why does it work in sqlplus but not sqr?

I already tried replacing the variables with literals
in the sqr and it still didn't work.

Thanks!
-Andrew

! I use these printed values to sub into the statement when I put it
into sqlplus.
show 'emplid = ' $emplid
show 'empl rcdnow= ' #Empl_RcdNo
show 'pay_end_dt = ' $Pay_end_dt

begin-select
A.EMPLID,
A.NAME,
B.DED_TAKEN,
B.DED_SUBSET_ID,
B.BENEFIT_RCD_NBR,
C.JOBCODE,
C.DEPTID,
C.GL_PAY_TYPE,
C.POSITION_NBR,
C.SHIFT,
C.EMPL_TYPE,
C.LOCATION,
C.HOURLY_RT,
C.EFFDT,
C.FICA_STATUS_EE,
D.BENEFIT_PROGRAM

  move 'Y' to $Found
  do Get-First-Work-State

FROM PS_PERSONAL_DATA A,
       PS_EMPLOYMENT B,
       PS_JOB C,
       PS_BEN_PROG_PARTIC D
WHERE A.EMPLID    = $EmplID
   AND B.EMPLID    = A.EMPLID
   AND C.EMPLID    = A.EMPLID
   AND D.EMPLID    = A.EMPLID
   AND B.EMPL_RCD = C.EMPL_RCD
   AND D.EMPL_RCD = C.EMPL_RCD
   AND B.EMPL_RCD = #Empl_RcdNo
   AND C.EFFDT =
       (SELECT MAX(EFFDT)
        FROM   PS_JOB
        WHERE  EMPLID    = $EmplID
          AND  EMPL_RCD = #Empl_RcdNo
          AND  EFFDT    <= $Pay_End_Dt)
   AND C.EFFSEQ =
       (SELECT MAX(EFFSEQ)
        FROM   PS_JOB
        WHERE  EMPLID    = $EmplID
          AND  EMPL_RCD = #Empl_RcdNo
          AND  EFFDT     = C.EFFDT)
   AND D.EFFDT =
       (SELECT MAX(EFFDT)
        FROM   PS_BEN_PROG_PARTIC
        WHERE  EMPLID    = $EmplID
          AND  EMPL_RCD = #Empl_RcdNo
          AND  EFFDT    <= $Pay_End_Dt)
end-select