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

Problem with some function

From: Uros Gruber <uros(at)sir-mag(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Problem with some function
Date: 2001-10-28 11:38:21
Message-ID: 4598394944.20011028123821@sir-mag.com (view raw or flat)
Thread:
Lists: pgsql-general
Hi!

i create some function like this

CREATE FUNCTION checkuser(varchar,varchar) RETURNS INTEGER AS '
DECLARE
   user ALIAS FOR $1;
   pwd ALIAS FOR $2;
BEGIN
   SELECT id_user FROM users WHERE username=user AND password=pwd AND allow_login = ''true'';
   IF id_user IS NULL THEN
      RAISE NOTICE ''User not found'';
      RETURN 0;
   ELSE
      UPDATE users SET last_login = ''NOW'', login_counts = login_counts+1;
      RETURN id_user;
   END IF;
END;
' LANGUAGE 'plpgsql';
  
What i want this function is to do? Check is username and pass is
correct and if it is, then update table users with last_login date and
counts this login.


WHen i execute this

devDbSir=# SELECT checkuser('uros','mypass');

i get this error.

ERROR:  unexpected SELECT query in exec_stmt_execsql()

what am i doing wrong, please help me with this.


P.S. executin SELECT id_user...... myself it works. also update
sentence.
-- 
by,
 Uros


Responses

pgsql-general by date

Next:From: Jean-Michel POUREDate: 2001-10-28 11:44:26
Subject: Re: UNICODE
Previous:From: Marko KreenDate: 2001-10-28 10:53:55
Subject: Re: UNICODE

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