1
我想執行這個函數。但它得到了錯誤說在postgresql函數中捕獲select查詢返回值並使用它
ERROR:
syntax error at or near ":="
LINE 7: select result:=MAX(path_history_id)as path INTO result from...
在這個功能我想:
- 執行
select with (MAX)
,它會從表中返回最大ID; - 捕獲該值(它是一個整數值);
- 將該值放入最後選擇查詢的條件。
我不能在postgresql找到一種方法來做到這一點。
CREATE OR REPLACE FUNCTION memcache(IN starting_point_p1 character varying, IN ending_point_p1 character varying)
RETURNS TABLE(path integer, movement_id_out integer, object_id_fk_out integer, path_history_id_fk_out integer, walking_distance_out real, angel_out real, direction_out character varying, time_stamp_out timestamp without time zone, x_coordinate_out real, y_coordinate_out real, z_coordinate_out real) AS
$BODY$
DECLARE result int;
BEGIN
select result:=MAX(path_history_id)as path INTO result from path_history_info where starting_point=starting_point_p1 and ending_point =ending_point_p1 and achieve='1';
return query
select * from movement_info where path_history_id_fk=result;
END;
$BODY$
LANGUAGE plpgsql
thanks.its work.it對我來說意義重大 – Dise