| From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> | 
|---|---|
| To: | Uros Gruber <uros(at)sir-mag(dot)com> | 
| Cc: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Problem with some function | 
| Date: | 2001-10-28 17:57:57 | 
| Message-ID: | Pine.BSF.4.21.0110280956120.76258-100000@megazone23.bigpanda.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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';
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Stephan Szabo | 2001-10-28 18:02:16 | Re: trigger function in plpgsql (newbie) | 
| Previous Message | Tom Lane | 2001-10-28 17:37:38 | Re: trigger function in plpgsql (newbie) |