I solved it. The statment worked as is, I just had to use dynamic SQL (put
the statement in a string and the EXECUTE the string). Here is what I did:
CREATE FUNCTION test(varchar) RETURNS int2 AS'
DECLARE
id_list ALIAS FOR $1;
query varchar;
BEGIN
query := '' INSERT INTO history (media_id, media_type) SELECT
media.media_id, media.media_type WHERE media.media_id IN ( '' || id_list ||
'')'';
EXECUTE query;
Now I can call this function like this
SELECT test( '24,25,26,27,28,29' );
and it will execute the INSERT statement for each value in the passed
varchar
-Thanks guys for your input
Adam