Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Select into problem
Michael O'Shea schrieb:
> Mladen Gogala wrote:
>
>> On Tue, 12 Dec 2006 13:32:50 -0800, Jun wrote: >> >>> SELECT STUD_AGE INTO v_cHP_MaxAge FROM STUDENT WHERE GDU = >>> '015346001002'; >> SELECT STUD_AGE INTO v_cHP_MaxAge FROM ( >> SELECT STUD_AGE FROM STUDENT WHERE GDU = '015346001002' >> UNION >> SELECT -1 AS STUD_AGE FROM DUAL >> ); >> >> That will never throw "NO_DATA_FOUND" exception. >> >> -- >> http://www.mladen-gogala.com
>> That will never throw "NO_DATA_FOUND" exception.
But to restrict it to only one row is not a big deal:
SELECT STUD_AGE INTO v_cHP_MaxAge FROM (
SELECT STUD_AGE FROM STUDENT WHERE GDU = '015346001002'
UNION
SELECT -1 AS STUD_AGE FROM DUAL
ORDER BY DECODE(STUD_AGE,-1,1,0)
)
WHERE ROWNUM <=1;
Best regards
Maxim Received on Wed Dec 13 2006 - 08:28:32 CST