我创建了一个包含聚合值的列的视图(以 varchar2 数据类型存储输出)。某些记录超出了最大限制,例如 varchar2(4000)。有人建议我使用 PL/SQL 函数来检查长度并在必要时构建一个字符串。
我检查过,并试图纠正语法错误,
CREATE OR REPLACE
FUNCTION SUBURL(col1 IN VARCHAR2, col2 IN varchar2)
RETURN varchar2
IS
v_result_string varchar2(4000);
v_length varchar2(4000);
BEGIN
IF (length (col1) + length (col2) ... <= 4000) then return col1 || col2 || ...
END IF;
-- build the string and check the length for every column you contatenate
v_result_string := col1;
if (length(v_result_string) + length (col2) > 4000) THEN
-- add as much of col2 as you can up to a total of 4000
v_length := 4000 - length(v_result_string);
v_result_string := v_result_string + substr(col2, 1, v_length);
return v_result_string;
end if;
end suburl;
这次有两个错误,
错误(7,35):PLS-00103:遇到符号“。” 预期以下情况之一时:。( ) , * % & = - + < / > at 是 mod 余数 not rem => <> or != or ~= >= <= <> and or like like2 like4 likec as between || member submultiset 符号“.” 被忽略了。
错误(7,76):PLS-00103:遇到符号“。” 当期望以下之一时:( - + case mod new null continue avg count current max min prior sql stddev sum variance execute forall merge time timestamp interval date pipe