Create or replace function cv_denik return number is
 cv messages.numcol2%type;
begin
insert into messages(numcol2,charcol2)
       values(seq_denik.currval,'currval je tady');
select numcol2 into cv from messages where charcol2='currval je tady';
delete from messages where charcol2='currval je tady';
return cv;
end;
/