Обсуждение: Variable number of arguments

Поиск
Список
Период
Сортировка

Variable number of arguments

От
robewald@gmx.net
Дата:
Hi,

I'm wondering if there is any possibility of passing a variable number
of arguments to SQL or PLPGSQL functions.
I tried with arrays:

create function test(integer,varchar(20)[]) returns oid as '
declare
    narg ALIAS FOR $1;
    args ALIAS FOR $2;
begin
    FOR i IN 0..nargs-1 LOOP
        RAISE NOTICE ''args is %'', args[i];
                        ^^^^ <--this is obviously wrong
    END LOOP
END;
'
language 'plpgsql';

so the problem is accessing the values in an array.

If there is another approach to pass a variable number of arguments
please tell me.

Thanks

Robert ü