Function returns error - Mailing list pgsql-sql

From Michael Long
Subject Function returns error
Date
Msg-id 49717.161.88.255.139.1086879689.squirrel@datalong.com
Whole thread Raw
In response to Re: Find out whether a view's column is indexed?  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Responses Re: Function returns error
List pgsql-sql
Hi All,

I am a relatively new user to postgres. I have created a function that compiles but
generates an error when executed. I know I am overlooking something simple. The
function and error are below.

CREATE OR REPLACE FUNCTION building_insert(varchar, int4, varchar) RETURNS int4 AS
'

/* Return code dictionary:       0 - Success       1 - Valid User, Insert Failed       2 - Invalid User, Abort
*/
DECLARE       p_user ALIAS FOR $1;       p_parcel_id ALIAS FOR $2;       p_name ALIAS FOR $3;

BEGIN
       IF p_user == \'mlong\' THEN               RETURN 2;       END IF;
       INSERT  INTO    building(        parcel_id,        name,        createdate    )VALUES(        p_parcel_id,
p_name,             now()    );
 

       RETURN 0;
END;
' LANGUAGE 'plpgsql' VOLATILE;

/* Query that generates error */
select building_insert('mlong', 20,'building 1');

ERROR:  operator does not exist: character varying == "unknown"
HINT:  No operator matches the given name and argument type(s). You may need to add
explicit type casts.
CONTEXT:  PL/pgSQL function "building_insert" line 14 at if

Thanks,
Mike


pgsql-sql by date:

Previous
From: Chris Gamache
Date:
Subject: Re: Schema + User-Defined Data Type Indexing problems...
Next
From: Tom Lane
Date:
Subject: Re: Schema + User-Defined Data Type Indexing problems...