I am new to psql so i am having a little trouble acommodating with the language. Here is the problem: I have created a small functions that returns true or false:
Expand|Select|Wrap|Line Numbers
- CREATE OR REPLACE FUNCTION DriverLogin(VARCHAR, VARCHAR)
- RETURNS BOOLEAN AS '
- DECLARE
- l_username ALIAS FOR $1;
- l_password ALIAS FOR $2;
- /* for checking the rowcount */
- myRowCount INTEGER;
- /* for getting @@IDENTITY, which PostgreSQL calls an OID */
- theOid OID;
- BEGIN
- select * from tblUsers where usertype=1 and username=l_username and userpassword=l_password;
- GET DIAGNOSTICS myRowCount := ROW_COUNT;
- IF myRowCount = 0 THEN
- return false;
- END IF;
- return true;
- END;
- ' LANGUAGE 'plpgsql';
PERFORM DriverLogin('a','f'); and it works but it does not show the result returned by the function.
When i tried to call it like this:
SELECT DriverLogin('a','f'); I get this error:
ERROR: SELECT query has no destination for result data
HINT: If you want to discard the results, use PERFORM instead.
CONTEXT: PL/pgSQL function "driverlogin" line 11 at SQL statement
So if anyone can please help me I would appreciate it. Thanks!