Note: no record with id = 4, two records with id = 3:
create table tq84_test (
id number,
val varchar2(10)
);
begin
insert into tq84_test values (1, 'one' );
insert into tq84_test values (2, 'two' );
insert into tq84_test values (3, 'three');
insert into tq84_test values (3, 'THREE');
insert into tq84_test values (5, 'five' );
commit;
end;
/
A procedure and function selecting from the table
The following function takes a number and returns the corresponding value from the test table:
create or replace function tq84_fnc(id number)
return varchar2
authid definer
as
ret varchar2(10);
begin
select val into ret
from tq84_test t
where t.id = tq84_fnc.id;
return ret;
end tq84_fnc;
/
This procedure does essentially the same, but does print the value rather then returning it:
create or replace procedure tq84_prc(id number)
authid definer
as
ret varchar2(10);
begin
select val into ret
from tq84_test t
where t.id = tq84_prc.id;
dbms_output.put_line(ret);
end tq84_prc;
/