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
---(end of broadcast)---
TIP 4: Don't 'kill -9' the postmaster