我正在尝试创建一个存储过程,该过程将采用 50 个字节的字符串并一次扫描一个字节以查找逗号。找到后,我想更新一个字段,然后继续扫描字符串以查找其他逗号。
我正在使用 Firebird 数据库并DBVisualizer
用于开发代码。
@delimiter ++;
CREATE PROCEDURE scan_for_comma(
lastname_field CHAR(50),
sr_bold_id int
)
RETURNS (
comma_flag varchar(1))
AS
declare variable max_bytes inv default 50;
declare variable I integer;
BEGIN
I = 0;
While
(I <= max_bytes)
DO
Begin
if (substring(name_field from I for 1) = ',') then
Begin
comma_flag = 'Y'
I = I +1
UPDATE sr_address
SET lastname = (substring(name_field from i for 1) = ' ')
WHERE bold_id = :sr_bold_id
end
ELSE
(substring(name_field from loop_cnt for 1) != ',') then
Begin
I = I +1
END
END
END
++
@delimiter ;++
我收到这个错误
14:45:34 [@DELIMITER - 0 行,0.000 秒]
命令处理
14:45:34 [CREATE - 0 行,0.000 秒]
[错误代码:335544569,SQL 状态:HY000]
GDS 异常. 335544569.
动态 SQL 错误 SQL 错误代码 = -104 令牌未知 - 第 21 行,第 12 列 14:45:34 [@DELIMITER - 0 行,0.000 秒]
命令已处理 ...
3 个语句已执行,0受影响的行,执行/获取时间:0.000/0.000 秒
[2 成功,0 警告,1 错误]
任何帮助/方向将不胜感激。
非常感谢。