[clug-talk] PL/PGSQL, Part Deux
Cirez Communications, inc.
jacirez at gmail.com
Tue Oct 25 16:42:54 PDT 2005
Just a follow up on my post from yesterday. What I had in mind was
something along the lines of what follows. Again, I used the login
mechanism as an example to illustrate a case where you would like a
conditional return...From what I have read so far, there is a far more
exotic way of doing this...But I'm not there yet..
CREATE OR REPLACE FUNCTION loginMechanism(t_row table_name, varchar,
varchar) RETURNS text AS $$
BEGIN
IF (t_row.username = $2) THEN
IF(t_row.password = $3) THEN
RETURN (t_row.firstname, t_row.middlename, t_row.lastname,
t_row.sessionid);
ELSE
RETURN (t_row.username,t_row.accessflag);
END IF;
ELSE
RAISE EXCEPTION 'Invalid username/password';
END IF;
END;
$$ LANGUAGE plpgsql;
--
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
-------------------Cirez Communications, inc.----------------
----------------------Juan Alberto Cirez---------------------
-----------------------Senior Consultant---------------------
-----------------------jacirez at gmail.com---------------------
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
Sunny and Beautiful Vancouver, Canada.
=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=
More information about the clug-talk
mailing list