From: | "Chris Baechle" <bangular(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | PL/PGSQL - character varying as function argument |
Date: | 2008-09-26 13:35:08 |
Message-ID: | af2c99310809260635j3cebd4a2vb551ac27db59052b@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I'm fairly new at PL/PGSQL and I'm trying to create a login function.
I want to pass the username and password to the function and return
the permission type that user has. Here's a shortened version of the
function with just the part giving me problems.
CREATE OR REPLACE FUNCTION user_checkCredentials(character varying)
RETURNS character varying AS
$BODY$
DECLARE
username ALIAS FOR $1;
permission record;
BEGIN
select into permission permtype from users;
RETURN permission.permtype;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE
COST 100;
When I try to run it with:
select user_checkCredentials("asdf");
I get the error:
ERROR: column "asdf" does not exist
LINE 1: select user_checkCredentials("asdf");
However if I use numbers, say an integer, and change to
user_checkCredentials(integer) and pass a number it works. I obviously
don't understand how function arguments work in PL/PGSQL so can
someone explain to me what's going on?
From | Date | Subject | |
---|---|---|---|
Next Message | Scott Marlowe | 2008-09-26 13:36:11 | Re: ]OT] Database structure question |
Previous Message | Pavel Stehule | 2008-09-26 12:11:16 | Re: Dynamically created cursors vanish in PLPgSQL |