Dynamic Array into pl/pgSQL function

Поиск
Список
Период
Сортировка
От Derrick Betts
Тема Dynamic Array into pl/pgSQL function
Дата
Msg-id 000a01c446d0$7fba6380$0200a8c0@main
обсуждение исходный текст
Ответы Re: Dynamic Array into pl/pgSQL function  ("derrick" <derrick@grifflink.com>)
Список pgsql-novice
 I looked around for an example of how I might accomplish this, but couldn't find anything.  Perhaps I'm using the wrong search words.

I want to input dynamic values into a function, with one of those values being a list of numbers:

CREATE OR REPLACE FUNCTION public.PopContacts(varchar, varchar)
  RETURNS SETOF casedata AS
'
DECLARE
c casedata%rowtype;
State alias for $1;
ListOfNumbers alias for $2;
rec RECORD;

BEGIN
  FOR rec IN SELECT caseid, name, address FROM Table1 WHERE area = State and caseId In (ListOfNumbers)
  LOOP
    c.caseid := rec.caseid;  c.name := rec.name; c.address := rec.name;
  RETURN NEXT c;
  END LOOP;
RETURN;
END;
'
LANGUAGE 'plpgsql' VOLATILE;

How can I get the ListOfNumbers into the function and then have the function use that ListOfNumbers in the manner shown above?  I realize that varchar is not the correct input type for the ListOfNumbers, but am unsure what to use to have it work properly. The length of the ListOfNumbers varies with each call to the function.  I am sending a Query string to the server from a client application.

I appreciate any ideas anyone may have.

Thank you,
Derrick
 

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Martin Hampl"
Дата:
Сообщение: Turn off Wal for bulk loaf input
Следующее
От: "derrick"
Дата:
Сообщение: Re: Dynamic Array into pl/pgSQL function