我具有以下功能并通过序列设置触发:
我想创建一个函数并触发每当我向 STRATEGY_SITES 表添加新行时,“SITE_NUM”字段将具有来自 SITENUM_SEQ 的新序列号。模式名称是 gismgr。
我收到以下错误:基础 DBMS 错误 [错误:控制到达触发过程结束而没有返回上下文:PL/pgSQL 函数 process_sites_edit()(gismgr.strategy_sites)::SQLSTATE=2F005][gismgr.startegy_sites]
CREATE OR REPLACE FUNCTION process_sites_edit() RETURNS TRIGGER AS $SITE_EDIT_TRIGGER$
begin
new.SITE_NUM := nextval('gismgr.SITENUM_SEQ');
end;
$SITE_EDIT_TRIGGER$ LANGUAGE 'plpgsql';
create TRIGGER SITE_EDIT_TRIGGER
before insert or update on STRATEGY_SITES for each row
EXECUTE PROCEDURE process_strategy_sites_edit();
CREATE SEQUENCE gismgr."SITENUM_SEQ" owned by gismgr.strategy_Sites.site_num
INCREMENT 1
START 19080
MINVALUE 19080
MAXVALUE 9999999999999999
CACHE 20;