CREATE PROCEDURE GetPersonYears()
language sqlscript as
v_age varchar(10) :='';
v_years varchar(2) :='';
cursor c_cursor1(v_age varchar(10)) for
select id,name || '' || last_name as "NAME",
days_between(DOB,NOW()) AS "AGE"
from person
begin
for cur_row as c_cursor1 do
if cur_row.age > 100 then
v_years := floor(cur_row.age/360);
insert into employee
values(cur_row.id,cur_row.name,v_years);
endif;
endfor;
end;