在Oracle PL/SQL中创建过程(或函数)时,不能指定varchar2参数的最大长度,只能指定数据类型.例如
create or replace procedure testproc(arg1 in varchar2) is
begin
null;
end;
Run Code Online (Sandbox Code Playgroud)
您是否知道可以作为Oracle中此过程的arg1参数传递的字符串的最大长度?
或者我应该?
(标题的灵感来自于Gary Myers的评论为什么Oracle varchar2有一个强制大小作为定义参数?)
考虑以下变量:
declare
-- database table column interfacing variable
v_a tablex.a%type; -- tablex.a is varchar2
-- PL/SQL only variable
v_b varchar2(32767); -- is this a poor convention ?
begin
select a into v_a from tablex where id = 1;
v_b := 'Some arbitrary string: ' || v_a; -- ignore potential ORA-06502
insert into tabley(id, a) values(1, v_a); -- tablex.a and tabley.a types match
v_b := v_b || ' More arbitrary characters';
end;
/
Run Code Online (Sandbox Code Playgroud)
变量v_a …