I am using the following query to return a single value:
select er.elig_code
from idm_elig_rule er
where ER.ROLE_CODE = role_code and ER.SERVICE_CODE = service_code;
When I substitute values for the variables and run it as a single SQL statement it will return just a single value like I want it too. However, when I place the statement in a cursor and loop through the results, it returns all rows in the table. I've also tried a "select into" statement but that still returns all 85 rows in the table. I have a unique index in the idm_elig_rule table that is a combination of the role_code, service_code and another column.
EDIT: Here's how I'm testing it out - using an anonymous block:
declare
role_code_in IDM_ELIG_RULE.ROLE_CODE%type := 'CEMP';
service_code_in IDM_ELIG_RULE.SERVICE_CODE%type := 'PORTL';
cursor get_elig_code is
select ER.ELIG_CODE
from idm_elig_rule er
where ER.ROLE_CODE = role_code_in and ER.SERVICE_CODE = service_code_in;
begin
for r in get_elig_code
loop
DBMS_OUTPUT.PUT_LINE(r.elig_code);
end loop;
end;
EDIT: I changed the names of the variables in the where clause and that resolved the issue.