hi, what is wrong with my newbie sql?

From: "Ronin" <jkoorts(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: hi, what is wrong with my newbie sql?
Date: 2006-09-25 09:15:58
Message-ID: 1159175758.025535.29770@e3g2000cwe.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi, the following sql returns "10" and not "20" as would be expected.

Where is the error? This would for sure work in any programming
language, why is this different?

CREATE FUNCTION test () RETURNS INTEGER AS '

DECLARE
k integer;

BEGIN
k = 10;
FOR k IN 1..10 LOOP
k = k +1;
END LOOP;

return k;
END;

' LANGUAGE 'plpgsql';

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Gurjeet Singh 2006-09-25 09:46:07 Re: in failed sql transaction
Previous Message Dawid Kuroczko 2006-09-25 09:09:57 Re: IF EXISTS