
May 22nd, 2012, 03:06 PM
|
 |
Contributing User
|
|
Join Date: Mar 2008
Location: Texas
Posts: 350
 
Time spent in forums: 3 Days 14 h 45 m 42 sec
Reputation Power: 6
|
|
|
Single row subquery errors during update
I'm getting back more than I want. I need to get the latest row in the PS_ACAD_STDNG_ACTN that has the academic standing code for students.
I thought if I max the effdt, strm, and effseq I would get back only one row. Especially effdt since a academic status is hardly ever updated on the same date.
PS_NTSR_GF_STUFILE will have multiple emplid's for students taking classes. PS_ACAD_STDNG_ACTN should have the last standing status for each student..(PRO = Probation, DIS = Dismissed).
PHP Code:
UPDATE PS_NTSR_GF_STUFILE a
SET a.NTSR_GF_ENRL_STAT = nvl((
SELECT b.GBSA_SUB1
FROM PS_GBSA_DTL b, PS_ACAD_STDNG_ACTN c
WHERE c.ACAD_STNDNG_STAT = b.GBSA_VALUE
AND b.GBSA_PRCS='NTSR_GDFT_AE'
AND b.GBSA_CRIT='ACAD_STANDING'
AND b.INSTITUTION = 'DL773'
AND c.EFFDT = (
SELECT MAX(f.EFFDT)
FROM PS_ACAD_STDNG_ACTN f
WHERE a.EMPLID = f.EMPLID
AND a.ACAD_CAREER = f.ACAD_CAREER
AND f.EFFDT <= SYSDATE)
AND c.STRM = (
SELECT MAX(d.STRM)
FROM PS_ACAD_STDNG_ACTN d
WHERE a.EMPLID = d.EMPLID
AND a.ACAD_CAREER = d.ACAD_CAREER)
AND c.EFFSEQ = (
SELECT MAX(e.EFFSEQ)
FROM PS_ACAD_STDNG_ACTN e
WHERE a.EMPLID = e.EMPLID
AND a.ACAD_CAREER = e.ACAD_CAREER)
AND c.INSTITUTION = (
SELECT GBSA_VALUE
FROM PS_GBSA_DTL
WHERE INSTITUTION = 'DL773'
AND GBSA_PRCS='NTSR_GDFT_AE'
AND GBSA_CRIT='DEFAULT_INSTITUTION')
), ' ');
|