Re: error in SELECT

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "P(dot)M" <pmdanger(at)yahoo(dot)com>
Cc: "PostgreSQL General \(EN\)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: error in SELECT
Date: 2006-05-27 15:37:35
Message-ID: 23481.1148744255@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"P.M" <pmdanger(at)yahoo(dot)com> writes:
> here is my function in PostgreSQL :
> CREATE OR REPLACE FUNCTION immense_sp001(VARCHAR,VARCHAR, service_nom VARCHAR, OUT result BOOLEAN, OUT error_message VARCHAR)
> RETURNS record LANGUAGE plpgsql
> AS '
> BEGIN
> DECLARE
> username varchar :=$1;
> strhash varchar :=$2;
> Profile_Detected INTEGER;
> Service_Already_Exist INTEGER;

> /* detect if the user logged in exists in database */
> SELECT count(*) INTO Profile_Detected FROM profiles WHERE login=username AND pwd=strhash;

The BEGIN goes after the variable declarations, not before them.

You're going to have some problems with those double-quoted string
literals too; that's not the correct syntax for string literals.
And you don't use "set" when assigning to a plpgsql variable.

Might be a good idea to practice on some toy functions until you've got
some familiarity with plpgsql syntax, rather than diving in with porting
many-line functions. A big function is too hard when you're trying to
fix many misconceptions at once.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2006-05-27 15:49:24 Re: error in SELECT
Previous Message Tom Lane 2006-05-27 15:30:03 Re: Incomplete dump?