Re: Problem with some function - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Problem with some function
Date
Msg-id Pine.BSF.4.21.0110280956120.76258-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Problem with some function  (Uros Gruber <uros@sir-mag.com>)
List pgsql-general
On Sun, 28 Oct 2001, Uros Gruber wrote:

> Hi!
>
> i create some function like this
>
> CREATE FUNCTION checkuser(varchar,varchar) RETURNS INTEGER AS '
> DECLARE
>    user ALIAS FOR $1;
>    pwd ALIAS FOR $2;
     id integer;
> BEGIN
    SELECT INTO id id_user FROM users WHERE username=user AND password=pwd
AND allow_login = ''true'';
-- You need to select into a variable here.

    IF id IS NULL THEN
>       RAISE NOTICE ''User not found'';
>       RETURN 0;
>    ELSE
>       UPDATE users SET last_login = ''NOW'', login_counts = login_counts+1;
-- Is this above really what you want?  You're not specifying the user to
-- update.  I think you probably want a WHERE on id or one like above.
       RETURN id;
>    END IF;
> END;
> ' LANGUAGE 'plpgsql';



pgsql-general by date:

Previous
From: The Cadaver
Date:
Subject: IDE
Next
From: Tom Lane
Date:
Subject: Re: trigger function in plpgsql (newbie)