error in SELECT

From: "P(dot)M" <pmdanger(at)yahoo(dot)com>
To: "PostgreSQL General \(EN\)" <pgsql-general(at)postgresql(dot)org>
Subject: error in SELECT
Date: 2006-05-27 15:20:47
Message-ID: 20060527152047.24417.qmail@web33204.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

i've just migrated a stored procedure from MySQl to PostgreSQL and i have the following error :
ERROR: syntax error at or near "SELECT" at character 371

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;
if (Profile_Detected = 1) then
/* detect if service already exists in database */
SELECT count(*)
INTO Service_Already_Exist
FROM immense.services
WHERE service_nom = service_name;
if (Service_Already_Exist = 0) then
/* to reset AUTO_INCREMENT field : service_id */
alter table services auto_increment=1;
/* service does not exist, so we can add it */
insert into immense.services
set service_name = service_nom;
set result = false;
set error_message="new service created";
else
/* service already exists in database and can not be created */
set result = true;
set error_message = "service already exists";
end if;
else
set result=true;
set error_message = "user does not exist";
end if;
END;
'

-----
What could it be ? I'm lost :-(
thanks for help.

Maileen


---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-05-27 15:30:03 Re: Incomplete dump?
Previous Message Benno Pütz 2006-05-27 14:36:29 Re: Incomplete dump?