我想在postgres函数中返回一个查询结果。我试过这个并且工作得很好:
CREATE OR REPLACE FUNCTION getIncomingAreaMovements(v1 integer)
RETURNS integer AS $$
DECLARE
BEGIN
return id_part_movement From part_movement where id_area_final_destination = $1;
END;
$$ LANGUAGE plpgsql;
事情是我需要一些东西来返回结果:
Select * From part_movement where id_area_final_destination = $1;
我需要什么回报或者我应该改变什么来实现这一目标?
答案 0 :(得分:4)
这可以通过一个简单的SQL函数来完成:
CREATE OR REPLACE FUNCTION get_data(v1 integer)
RETURNS setof part_movement
AS
$$
Select *
From part_movement
where id_area_final_destination = v1;
$$ LANGUAGE sql;
手册中可以找到更多细节和示例:
http://www.postgresql.org/docs/current/static/xfunc-sql.html#XFUNC-SQL-FUNCTIONS-RETURNING-SET
答案 1 :(得分:0)
有效的是:
name id indid doampg ioampg oampgtrips status3 status2 ipgtrips first root distribution usagecnt segment status maxrowsperpage minlen maxlen maxirow keycnt keys1
"dbo.index_name" 1259148500 3 0 0 0 0 0 0 0 0 0 0 1 0 0 15 15 15 2 81 00 06 00 01 00 00 bf 08 00 00 00 01 00 00 00 81 00 00 00 00 00 00 2d 06 00 00 00 09 00 00 00