dojjol
asked on
exists in pl/sql
Hello All,
I am trying to run the block but it fails at where exists.
Please help
DECLARE
status_val number;
BEGIN
FOR to_delete_person IN
(
SELECT ps.id
FROM person ps;
)
LOOP
status_val := 0;
select 1 into status_val from dual where exists
(
select status from person_status
where person_status.id = ps.id
);
if(status_val = 1) then
dbms_output.put_line(' person '||to_delete_person.id);
end if;
END LOOP;
END;
I am trying to run the block but it fails at where exists.
Please help
DECLARE
status_val number;
BEGIN
FOR to_delete_person IN
(
SELECT ps.id
FROM person ps;
)
LOOP
status_val := 0;
select 1 into status_val from dual where exists
(
select status from person_status
where person_status.id = ps.id
);
if(status_val = 1) then
dbms_output.put_line(' person '||to_delete_person.id);
end if;
END LOOP;
END;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>Missed that. Yes it should be:
Yeah, sorry, should've been more specific - I was referring to the OP, as your post was already clear enough!
Yeah, sorry, should've been more specific - I was referring to the OP, as your post was already clear enough!
>>I was referring to the OP
I figured that. But it pointed out that my first post was incorrect because of it. Good catch!
I figured that. But it pointed out that my first post was incorrect because of it. Good catch!
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Missed that. Yes it should be:
select count(*) into status_val from person_status where person_status.id = to_delete_person.id;