プロシージャ引数の名前表記法

 


(8.0.33)
https://dev.mysql.com/doc/refman/8.0/en/call.html
https://stackoverflow.com/questions/4245530/named-parameters-for-stored-procedures-in-mysql


名前表記法はできない模様

念のため使用できないことを確認


drop procedure proc1;

delimiter //
create procedure proc1(in param1 int, in param2 int)
begin
  declare i int;
  set i = param1;
  while i <= param2 do
    select i;
    set i = i + 1;
  end while;
end
//
delimiter ;

call proc1(1, 10);
call proc1(param2 =>10, param1 =>1);

ERROR 1064 (42000): You have an error in your SQL syntax; 
check the manual that corresponds to your MySQL server version for the right syntax to use near '=>10, param1 =>1)' at line 1

 

 

(23c)
https://www.shift-the-oracle.com/plsql/positional-named-notation.html
https://docs.oracle.com/cd/F82042_01/lnpls/plsql-subprograms.html#GUID-A5DA8CF5-1BCC-4ABE-9B68-DB593FF1D2CC

set serveroutput on
create or replace procedure proc1(param1 in number, param2 in number )
as
begin
  for i in param1..param2 loop
    dbms_output.put_line(i);
  end loop;
end;
/
show error;

exec proc1(1, 10);
exec proc1(param2 =>10, param1 =>1);
exec proc1(1, param2 =>10);

名前表記法、混合表記法ともに可能

 

(15)
https://www.postgresql.jp/document/15/html/sql-syntax-calling-funcs.html

create or replace procedure proc1(param1 in int, param2 in int)
language plpgsql
as $$
declare
begin
  for i in param1..param2 loop
    raise info '%', i;
  end loop;
end;
$$;

call proc1(1, 10);
call proc1(param2 =>10, param1 =>1);
call proc1(1, param2 =>10);


名前表記法、混合表記法ともに可能

 

(2022)
https://learn.microsoft.com/ja-jp/sql/t-sql/language-elements/execute-transact-sql?view=sql-server-ver16

create or alter procedure proc1(@param1 int, @param2 int)
as
begin
  set nocount on;
  declare @i int;
  set @i = @param1;
  while (@i <= @param2)
    begin
      print @i
      set @i = @i + 1;
    end
end
go


exec proc1 1, 10;
exec proc1 @param2 = 10, @param1 = 1;
exec proc1 1, @param2 = 10;

名前表記法、混合表記法ともに可能