And*_*rey 2 oracle plsql oracle-sqldeveloper
我正在尝试创建一个 pl/sql 函数(我第一次使用 pl/sql 函数),它将 10 进制数字转换为 26 进制字符串(我的 26 进制将是 A..Z)。
create or replace function generateId(numericId IN NUMBER) RETURN VARCHAR2 AS
declare
type array_t is varray(26) of CHAR;
char_array array_t := array_t('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
res varchar2(3);
targetBase INTEGER := char_array.count;
begin
LOOP
res = char_array[REMAINDER(numericId, targetBase)] + result;
numericId = numericId / targetBase;
EXIT WHEN (numericId = 0);
RETURN res;
end;
Run Code Online (Sandbox Code Playgroud)
我收到的错误是:
Error(2,1): PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following: begin function pragma procedure subtype type <an identifier> <a double-quoted delimited-identifier> current cursor delete exists prior external language The symbol "begin" was substituted for "DECLARE" to continue.
Run Code Online (Sandbox Code Playgroud)
我的猜测是我将声明粘贴到了错误的位置,但我不知道它应该放在哪里。
| 归档时间: |
|
| 查看次数: |
2928 次 |
| 最近记录: |