Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Exists clause returns No Data Found
I am having trouble.
I am trying to write a query into a package which will use the 'Exists' clause.
I am trying to use parameters to decide if a row matching the one I am about to enter exists, ie:
I have a number of courses, I want to be able to run the same 'course' using different dates, so if the course code exists, and it matches the date that I am about to insert, I know it is a duplicate, and I want to prevent that.
I have tried the following:
select 1 into varExists from Dual
where Exists (select max(CourseID) from sch_Course_Table where
CourseNumber = varCourseNumber and deptCodeId =varDeptCodeID and
season=varseason and courseYear=varcourseYear);
This works fine as long as the query returns a row - however, whenever the query inside the exists statement does not contain rows - the package/procedure stops with a 'No Data Found' error.
The purpose of this is to allow branching logic, if exists is true - update, if exists is false insert.
If exists is false it dies.
What am I doing wrong??
Thank you. Received on Fri Nov 30 2001 - 17:20:18 CST
![]() |
![]() |