Variable number or arguments to a function possible?

Поиск
Список
Период
Сортировка
От Chris Ruprecht
Тема Variable number or arguments to a function possible?
Дата
Msg-id 08F9706F-C603-46A2-8D42-5799D700DCE7@ruprecht.org
обсуждение исходный текст
Ответы Re: Variable number or arguments to a function possible?  ("Milen A. Radev" <milen@radev.net>)
Re: Variable number or arguments to a function possible?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-sql
Hello everybody,

Is it possible to create a function that can take a variable number of
arguments?
I would like to write a function that creates a new record in the
database. Based on what I send it, it should create a record in the
appropriate table.

Simple pseudo-code example:

... function create_record( varchar [,...] ) returns bigint as

if $1 = 'state' then insert into state ( $2, $3 ) // $2 being state
name, and $3 state code
if $1 = 'phone' then insert into phone ( $4::bigint, $2, $3 ) // $2 =
phone number, $3 = phone type, $4 = id of person that ownes the phone

and so on.

How would I declare that function?

Thanks.


best regards,
chris
--
chris ruprecht
database grunt and bit pusher extraordinaíre



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: varchar value comparisons not working?
Следующее
От: "Milen A. Radev"
Дата:
Сообщение: Re: Variable number or arguments to a function possible?