关于这个错误,有很多类似的问题,但是似乎没有一个问题可以解决我的问题。我在PostgreSql中创建了以下存储过程:
CREATE OR REPLACE FUNCTION "MySchema".UserAccountInsert(
id bigint,
lang varchar(3),
nname varchar(40),
email varchar(40),
email_conf boolean,
status smallint,
status_update bigint,
creation bigint,
preferences json)
RETURNS bigint AS $BODY$
DECLARE
rowc INTEGER;
ret_id bigint;
BEGIN
SELECT "ID" FROM "MySchema"."USER_ACCOUNT"
WHERE "ID" = id OR "NAME" = nname OR "EMAIL" = email
LIMIT 1;
GET DIAGNOSTICS rowc = ROW_COUNT;
IF ( rowc > 0 ) THEN
ret_id = -1; /* Unsuccessful */
ELSE
IF ( id <= 0 ) THEN
INSERT INTO "MySchema"."USER_ACCOUNT" ("LANG","NAME","EMAIL","EMAIL_CONF","STATUS","STATUS_UPDATE","CREATION","PREFERENCES")
VALUES (lang,nname,email,email_conf,status,status_update,creation,preferences) RETURNING "ID" INTO ret_id;
ELSE
INSERT INTO "MySchema"."USER_ACCOUNT" ("ID", "LANG","NAME","EMAIL","EMAIL_CONF","STATUS","STATUS_UPDATE","CREATION","PREFERENCES")
VALUES (id, lang,nname,email,email_conf,status,status_update,creation,preferences);
ret_id = id;
END IF;
END IF;
RETURN ret_id;
END; $BODY$
LANGUAGE plpgsql;
我试图用以下命令从pgAdmin III调用它:
SELECT "MySchema".UserAccountInsert(
1000::bigint,
'ENG'::varchar(3),
'name1000'::varchar(40),
'email1000'::varchar(40),
'f'::boolean,
1::smallint,
1391878008121::bigint,
1391878008121::bigint,
'{}'::json) as ret_id;
但我收到以下错误消息:
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function "MySchema".useraccountinsert(bigint,character varying,character varying,character varying,boolean,smallint,bigint,bigint,json) line 6 at SQL statement
我应该如何调用我的函数?
跟随a_horse_with_no_name的评论,我对我的函数进行了如下修改:
SELECT COUNT(*) INTO rowc FROM "MySchema"."USER_ACCOUNT"
WHERE "ID" = id OR "NAME" = nname OR "EMAIL" = email
LIMIT 1;
/* GET DIAGNOSTICS rowc = ROW_COUNT; */
而且有效!
问题内容: 我创建了一个函数以插入以下内容 并创建的是 当执行上述功能时 选择funcInsert(666,13,‘2014-06-06’ 得到这个错误 错误:查询没有结果数据的目标上下文:SQL语句中的PL / pgSQL函数procgtab83(integer,integer,date)第3行 问题答案: 它可以比普通sql简单得多
我正在实现房间数据库。这是我的POJO类 这是DAO类 在运行我的代码时,我收到以下错误
不确定我是不是漏掉了什么。 如有任何建议,将不胜感激。
我正在尝试在Firebase中进行简单搜索以从我的Firebase数据中返回数据,但没有任何返回。 JSON结构 我的Firebase搜索代码如下 但一旦代码被执行,它就会返回null。还有一种方法可以搜索特定字段。
我刚刚开始学习平均堆栈,我被卡住了。我需要将下面的查询数据发送到前端。 我试过这样做,但没有成功