Function returns error

From: "Michael Long" <mlong(at)datalong(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Function returns error
Date: 2004-06-10 15:01:29
Message-ID: 49717.161.88.255.139.1086879689.squirrel@datalong.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2004-06-10 15:38:42 Re: Function returns error
Previous Message Chris Gamache 2004-06-10 14:34:54 Re: Schema + User-Defined Data Type Indexing problems...