Skip site navigation (1) Skip section navigation (2)

Re: Problem with some function

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: (view raw or whole 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 '
>    user ALIAS FOR $1;
>    pwd ALIAS FOR $2;
     id integer;
    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.

>       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';

In response to

pgsql-general by date

Next:From: Stephan SzaboDate: 2001-10-28 18:02:16
Subject: Re: trigger function in plpgsql (newbie)
Previous:From: Tom LaneDate: 2001-10-28 17:37:38
Subject: Re: trigger function in plpgsql (newbie)

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group