0

I am fairly new to Postgres and would like help with writing function that has an array as input parameter. I am using the function for a SSRS report and would like to add multiselect functionality

CREATE OR REPLACE FUNCTION foo(facid bigint, dptname text[])
RETURNS SETOF tmpdb AS
$BODY$
select * from tblitem
where dptname = $2 and facid = $1
$BODY$
LANGUAGE sql VOLATILE;

In the dptname you can choose either dress or shoes but would like to display result set of choosing both. VARIADIC is not an option because of the version.

Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
katie
  • 23
  • 5

1 Answers1

0
CREATE OR REPLACE FUNCTION foo(facid bigint, dptname text[])
   RETURNS SETOF tblitem AS
$BODY$
select * from tblitem
where  facid = $1
and    dptname = ANY($2)
$BODY$
LANGUAGE sql STABLE;
Community
  • 1
  • 1
Erwin Brandstetter
  • 605,456
  • 145
  • 1,078
  • 1,228
  • I could have sworn I tried ANY yesterday.. ANYway, it worked! Thanks for saving me a rewrite! and some good info on stable – katie May 19 '15 at 16:39