From: | "Bob Whitehouse" <bwhitehouse(at)geeknest(dot)com> |
---|---|
To: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | looping through records |
Date: | 2001-04-18 17:23:08 |
Message-ID: | 011501c0c82c$3d7a10e0$a6a0fea9@amsite.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
I'm trying to create a function that loops through records returned from a
query. This is what I came up with but it doesn't work. Can anyone tell me
what I'm doing wrong?
CREATE FUNCTION test_loop(INT4, VARCHAR)
RETURNS INT4
AS 'DECLARE
int_key ALIAS FOR $1;
var_test VARCHAR;
BEGIN
var_test := $2;
FOR row IN SELECT * FROM companies LOOP
UPDATE companies SET name = var_test;
END LOOP;
RETURN int_key;
END;'
LANGUAGE 'plpgsql';
Here's how I call the test loop and the error I get:
db=# SELECT test_loop(1, 'testing');
ERROR: parse error at or near ";"
db=#
Thanks, Bob
From | Date | Subject | |
---|---|---|---|
Next Message | Bob Whitehouse | 2001-04-18 20:09:47 | looping through records... |
Previous Message | David Olbersen | 2001-04-18 16:50:42 | Re: < Int4 - limit > |