错误:查询没有postgres中结果数据的目标 [英] ERROR: query has no destination for result data in postgres
本文介绍了错误:查询没有postgres中结果数据的目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
CREATE OR REPLACE FUNCTION master.test2(tehsil text, district text, state text, flag text)
RETURNS setof master.population AS
$BODY$
BEGIN
IF flag='A' THEN
select Count(*) from master.population where income in('1','2')and statecode=state;
ELSIF flag='B' THEN
select Count(*) from master.population where income in('1','2') and statecode=state and districtcode=district ;
ELSIF flag='C' THEN
select Count(*) from master.population where income in('1','2') and statecode=state and districtcode=district and tehsilcode=tehsil;
ELSE
select Count(*) from master.population where income in('1','2');
END IF;
END;
$BODY$
LANGUAGE plpgsql
抛出错误:
Throwing an error:
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 master.test2(text,text,text,text) line 6 at SQL statement
推荐答案
BODY
BEGIN
IF flag = ' A' 那么
选择计数(*)来自 master.population 其中 income in (' 1',' 2')和 statecode = state;
ELSIF flag = ' B' 那么
选择计数(*)来自 master.population where income in (' 1',' 2')和 statecode = state 和 districtcode = district;
ELSIF标志= ' C' 那么
选择计数(*)来自 master.population where income in (' 1',' 2')和 statecode = state 和 districtcode = district 和 tehsilcode = tehsil;
ELSE
选择计数(*) 来自 master.population 其中收入 ( ' 1',' 2 跨度>);
END IF ;
END ;
BEGIN IF flag='A' THEN select Count(*) from master.population where income in('1','2')and statecode=state; ELSIF flag='B' THEN select Count(*) from master.population where income in('1','2') and statecode=state and districtcode=district ; ELSIF flag='C' THEN select Count(*) from master.population where income in('1','2') and statecode=state and districtcode=district and tehsilcode=tehsil; ELSE select Count(*) from master.population where income in('1','2'); END IF; END;
BODY
这篇关于错误:查询没有postgres中结果数据的目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文