Функция
CREATE OR REPLACE FUNCTION olo_insert_operator(p_name character varying, p_login character varying, p_password character varying, p_email character varying, p_fullname character varying, p_pic_link character varying)
RETURNS integer AS
$BODY$
DECLARE
tb_row olo_operators%ROWTYPE;
l_id integer := 0;
l_status integer := 2;
BEGIN
SELECT * INTO tb_row FROM olo_operators WHERE op_login = p_login;
IF FOUND THEN
RAISE EXCEPTION 'Такой логин уже есть!';
END IF;
INSERT INTO olo_operators (
op_name,
op_login,
op_password,
op_email,
op_fullname,
op_pic_link,
status_id)
VALUES (
p_name,
p_login,
crypt(p_password, gen_salt('md5')),
p_email,
p_fullname,
p_pic_link,
l_status
)
RETURNING l_id = op_id;
RETURN l_id;
END
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
ALTER FUNCTION olo_insert_operator(character varying, character varying, character varying, character varying, character varying, character varying) OWNER TO postgres;
----Запуск функции
select olo_insert_operator('Дима','Dim','0258977','tv@mail.ru','Петров Дима','NOT')
---Ответ
ERROR: query has no destination for result data
CONTEXT: PL/pgSQL function "olo_insert_operator" line 25 at SQL statement
********** Ошибка **********
ERROR: query has no destination for result data
SQL state: 42601
Контекст:PL/pgSQL function "olo_insert_operator" line 25 at SQL statement
--------
ЧТО НЕ ТАК??
returning into..