oracle PLSQL 符号“=>”的含义
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10941594/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Meaning of PLSQL symbol "=>"
提问by Arav
What does the =>
symbol mean in PL/SQL? e.g.
=>
PL/SQL中的符号是什么意思?例如
GetAttrNumber(toitemtype => toitemtype,
toitemkey => toitemkey,
toactid => toactid)
回答by DCookie
That is the keyword/value notation for passing parameters to a PL/SQL procedure or function.
这是将参数传递给 PL/SQL 过程或函数的关键字/值表示法。
The left side is the name of the parameter, the right is the value being passed.
左边是参数名,右边是传递的值。
It's useful when you don't want to keep to a specific ordering of parameters, or for self-documenting code.
当您不想保持参数的特定顺序或自记录代码时,它很有用。
回答by DJPeter
The keyword/value notation can be very useful if you have a long list of parameters and only need to specify subset of them. Especially if you want to skip some of the parameters in the middle of the list of parameters (this requires the skipped parameters to use DEFAULT values). As an example if you have a procedure like this:
如果您有很长的参数列表并且只需要指定它们的子集,关键字/值表示法会非常有用。特别是如果你想跳过参数列表中间的一些参数(这需要跳过的参数使用 DEFAULT 值)。例如,如果您有这样的程序:
PROCEDURE my_proc(
p_param1 NUMBER DEFAULT 1
, p_param2 NUMBER DEFAULT 2
, p_param3 NUMBER DEFAULT 3
, p_param4 NUMBER DEFAULT 4
, p_param5 NUMBER DEFAULT 5
);
Now you can call my_proc() only with only first and last parameter,
现在您只能使用第一个和最后一个参数调用 my_proc(),
my_proc(p_param1 => value1, p_param5 => value2);
my_proc(p_param1 => value1, p_param5 => value2);