Link to home
Create AccountLog in
Avatar of thomasbau65
thomasbau65

asked on

Postgres 8.4 Create Function

Hi All
I'm trying to have Hipergate (www.hipergate.org) to run
After the installation I can not login
It seems that a function, which checks the user name and password dose not exist on the database
When looking at the source code of hipergate, I found the following script, which is generating the missing function.
 
CREATE FUNCTION k_sp_autenticate (CHAR, VARCHAR) RETURNS SMALLINT AS '

DECLARE
    Password  VARCHAR;
    DtCancel  TIMESTAMP;
    DtExpire  TIMESTAMP;
    Activated SMALLINT := NULL;
    CoStatus  SMALLINT := 1;

BEGIN
  SELECT tx_pwd,bo_active,dt_cancel,dt_pwd_expires INTO Password,Activated,DtCancel,DtExpire FROM k_users WHERE gu_user=$1;

  IF Activated IS NULL THEN

    CoStatus := -1;

  ELSE

    IF Password<>$2 AND Password<>''(not set yet, change on next logon)'' THEN

      CoStatus := -2;

    ELSE

      IF Activated=0 THEN
        CoStatus := -3;
      END IF;

      IF age(DtCancel)<INTERVAL ''0 secs'' THEN
        CoStatus := -8;
      END IF;

      IF age(DtExpire)<INTERVAL ''0 secs'' THEN
        CoStatus := -9;
      END IF;

    END IF;

  END IF;

  RETURN CoStatus;
END;
' LANGUAGE 'plpgsql';
GO;

CREATE SEQUENCE seq_k_webbeacons INCREMENT 1 START 1
GO;

Open in new window

The problem is, it wont run :-) I tried several things but its getting worse and worse  
Can some one help me correct this
Thanks for helping out
th*
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Hi, what is the error message you get when you try to run the code above?
Avatar of thomasbau65
thomasbau65

ASKER

ERROR:  syntax error at or near "GO"
LINE 44: GO;
         ^
Removing the GO

ERROR: language "plpgsql" does not exist
SQL state: 42704
Hint: Use CREATE LANGUAGE to load the language into the database.

if I change plpgsql to SQL

ERROR:  syntax error at or near "VARCHAR"
LINE 4:     Password  VARCHAR;
                      ^
ASKER CERTIFIED SOLUTION
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer