プロシージャ

create or replace procedure proc1(p1 in integer) as

ret integer;

begin
update tab1 set col1 = p1;
commit;
exception when others then
raise;
end;
/

execute proc1(999);

 

SHOW PROCEDURE STATUS\G
SHOW CREATE PROCEDURE proc1;


delimiter //

CREATE PROCEDURE proc1 (OUT param1 INT)
BEGIN
SELECT COUNT(*) INTO param1 FROM tab1;
END//

delimiter ;

CALL proc1(@a);
SELECT @a;

delimiter //
create procedure pram_test( in p_in int,
out p_out int,
inout p_inout int)
begin
select p_in,p_out,p_inout;
set p_in = 100,p_out = 200, p_inout = 300;
end//
delimiter ;

set @v_in = 0, @v_out = 0, @v_inout = 0;
call pram_test(@v_in,@v_out,@v_inout);
select @v_in,@v_out,@v_inout;

 


(11)
create procedure proc1()
language plpgsql
as $$
begin
create table a(aid int);
create table b(bid int);
commit;
create table c(cid int);
rollback;
end;
$$;

call proc1();

 


CREATE PROCEDURE dbo.proc1(@iEno int)
AS
BEGIN
DECLARE @iCnt int;
SET @iCnt = @iEno + 1;

UPDATE tab1
SET col2 = 0
WHERE col1 = @iCnt;
END
GO

EXEC test.dbo.proc1 0;
GO