为什么oracle plsql varchar2 变量需要大小而参数不需要?

2021-12-24 00:00:00 oracle plsql varchar2

假设你有这个程序:

PROCEDURE f (param VARCHAR2)
IS 
   var VARCHAR2(10);
BEGIN
   var := 'hi';
END f;

我想了解为什么 var 需要指定长度,而 param 不需要.我很难在 oracle 文档中找到相关信息.

I would like to understand why var needs a length specified, but param does not. I'm having a hard time finding information about this in the oracle docs.

推荐答案

Oracle 数据库从调用过程的环境中导出参数的长度、精度和小数位数."

"Oracle Database derives the length, precision, and scale of an argument from the environment from which the procedure is called."

请查看此相关问题.

参考:Oracle® 数据库 SQL 参考 10g 第 2 版(10.2)请查看语义/参数/数据类型.

Reference: Oracle® Database SQL Reference 10g Release 2 (10.2) Please look under semantics / argument / datatype.

相关文章