pras k
pras k

Reputation: 27

How to pass multiple values like 'param1','param2','param3'...for N number to a stored procedure in postgresql?

For the parameter wellid, I have to pass 'well1','well2','well3'....

create or replace procedure  aoi(
wellid text,
INOUT cumoil numeric,INOUT cumgas numeric) 

AS $BODY$

begin

SELECT SUM(cast(a.oil as decimal)) as cumoil,
SUM(cast(a.gas as decimal)) as cumgas

into cumoil,cumgas

from XYZ a   where "Well ID" in (wellid)
GROUP BY a."Well ID";

commit;
end;$BODY$;

Upvotes: 0

Views: 158

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 246083

Use an array:

  • for the parameter, use data type text[]

  • pass the array as '{value1,value2,value3}'

  • compare with "Well ID" = ANY (wellid)

Upvotes: 2

Related Questions