对于以下函数,我收到错误:
错误:查询没有结果数据的目的地
语境:PL / pgSQL函数“注册”第19行在SQL语句
错误是指插入语句(当我发表评论时,错误消失了)我不知道它试图告诉我什么。
有人可以帮忙吗?感谢。
CREATE OR REPLACE FUNCTION registration( wr text ) RETURNS integer AS $rL$
DECLARE
eml text;
pwd text;
emid integer;
rowt Email%ROWTYPE;
BEGIN
eml := getWebVarValue( wr , 'email' );
select * into rowt from Email where email_email = eml;
if rowt IS NOT NULL THEN
RAISE EXCEPTION 'email address, %, already registered.' , eml;
END IF;
pwd := getWebVarValue( wr , 'password' );
if pwd is null then
RAISE EXCEPTION 'No password specified in registration.';
END IF;
INSERT INTO Email VALUES (eml,pwd) RETURNING Email.email_id as emid;
RETURN emid;
END;
$rL$ LANGUAGE plpgsql;
Email.email_id声明为:
email_id integer DEFAULT nextval('email_email_id_seq':: regclass)NOT NULL,
答案 0 :(得分:1)
INSERT INTO table_name
VALUES (things)
RETURNING some.expression
INTO variable_name;
您使用AS
代替INTO
。