我正在将数据库从 MS SQL Server 传输到 PostgreSQL,但此触发器有问题:
CREATE TRIGGER added_clients ON client
FOR INSERT
AS
BEGIN
DECLARE cursor_inserted CURSOR
FOR SELECT name, surname FROM inserted;
OPEN cursor_inserted
DECLARE @name varchar(15), @surname varchar(20)
FETCH NEXT FROM cursor_inserted INTO @name, @surname
WHILE @@FETCH_STATUS = 0
BEGIN
print 'Added: '+@name+' '+ @surname
FETCH NEXT FROM cursor_inserted INTO @name, @surname
END
CLOSE cursor_inserted
DEALLOCATE cursor_inserted
END
GO
postgreSQL 中 @@FETCH_STATUS 的等价物是什么?
已找到 PostgreSQL 中 @@fetch_status 的等效项。
您可以在这里找到更多信息:https://www.postgresql.org/docs/9.1/static/plpgsql-statements.html#PLPGSQL-语句-诊断 https://www.postgresql.org/docs/9.1/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS
在触发器中,您只需要编写 WHILE (FOUND) 而不是 @@fetch_status = 0。
我希望你觉得我的回答有用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)