The following are Create Procedure statement examples:
create procedure mark_emp
(id integer not null, label varchar(100)) as
begin
update employee
set comment = :label
where id = :id;
if iirowcount = 1 then
message 'Employee was marked';
commit;
return 1;
else
message'Employee was not marked - record error';
rollback;
return 0;
endif;
end;
create procedure add_n_rows
(base integer not null, n integer,
label varchar(100)) as
declare
limit integer;
err integer;
begin
limit = base + n;
err = 0;
while (base < limit) and (err = 0) do
insert into blocks values (:label, :base);
if iierrornumber > 0 then
err = 1;
else
base = base + 1;
endif;
endwhile;
return :base;
end;
create procedure gttproc
(gtt1 set of (col1 int, col2 float not null, col3 char(8))) as
begin
...
insert into table1
select * from gtt1;
...
end;
create procedure getnamezip (IN custno int not null, OUT custname, OUT custzip) as
begin
...
select c_name, c_zip into :custname, :custzip from customer where c_id = :custno;
...
end;