Thread: Variable number of arguments

Variable number of arguments

From
robewald@gmx.net
Date:
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 ü