Skip to content

Instantly share code, notes, and snippets.

@m-sedl
Created October 2, 2022 18:50
Show Gist options
  • Save m-sedl/43417d1d22ef7be7c859165c7328115a to your computer and use it in GitHub Desktop.
Save m-sedl/43417d1d22ef7be7c859165c7328115a to your computer and use it in GitHub Desktop.
drop sequence log_id_seq;
create sequence log_id_seq
start with 0
increment by 1;
create table debug_log (
id number constraint log_id primary key,
lod_time date constraint log_time_nl not null,
message varchar(2000) constraint message_not_null not null,
msg_source varchar(2000) constraint source_not_null not null
);
create or replace procedure get_oldest_and_youngest_workers
is
begin
declare
oldest EMP.hiredate%TYPE;
youngest EMP.hiredate%TYPE;
begin
select hiredate into oldest from EMP order by hiredate asc offset 0 rows fetch next 1 rows only;
select hiredate into youngest from EMP order by hiredate desc offset 0 rows fetch next 1 rows only;
insert into debug_log values(log_id_seq.nextval, sysdate, 'oldest = ' || oldest || ' youngest = ' || youngest, 'get_oldest_and_youngest_workers');
end;
end;
/
begin
get_oldest_and_youngest_workers;
get_oldest_and_youngest_workers;
end;
/
select * from debug_log;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment