Hello all,
I have this rather simple function, which I am unable to compile successfully:
create or replace function lab_exists (p_in_labno worklist.labno%type, p_in_test test_desc.test_n%type) return boolean is
v_exists boolean;
v_number number;
begin
-- determine table name based on the test number and verify if labno already exists in that table
select count(*) into v_number from (select table_name from test_desc where test_n = p_in_test)
where labno = p_in_labno;
-- return true or false accordingly
if v_number = 0 then
v_exists := false;
else
v_exists := true;
end if;
return v_exists;
end;
It is obvious, that it has to do with the 'table name' after the FROM keyword.
Why can't I assign a table name dynamically?
Or, if I can, what am I doing wrong?
Thank you.