incorrect syntax for 'plpgsql' function to test boolean values

From: Ferindo Middleton Jr <fmiddleton(at)verizon(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: incorrect syntax for 'plpgsql' function to test boolean values
Date: 2005-08-07 02:52:24
Message-ID: 42F57768.6090702@verizon.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm trying to write a function and trigger to validate that user data
entry for boolean values makes sense before being inserted or updated
into my database. I have the following trigger:

CREATE TRIGGER trigger_registration_and_attendance
BEFORE INSERT OR UPDATE
ON registration_and_attendance
FOR EACH ROW
EXECUTE PROCEDURE trigger_insert_update_registration_and_attendance();

Here is the problem: Below is the first part of the function called
from the above trigger

1: CREATE FUNCTION trigger_insert_update_registration_and_attendance()
2: RETURNS opaque
3: AS 'DECLARE
4: schedules_record RECORD;
5: BEGIN
6:
7: /* To ensure the integrity of boolean variables this database
stores to identify the
8: status of a registration */
9: IF ((new.enrolled == true) && (new.waitlisted == true))
10: THEN RAISE EXCEPTION ''Participant cannot be Enrolled AND
Waitlisted at the same time.'';
11: END IF;
12: IF ((new.enrolled == true) && (new.cancelled == true))
13: THEN RAISE EXCEPTION ''Participant cannot be Enrolled and
Cancelled at the same time.'';
14: END IF;

I get he following error message when I try inserting a record:

ERROR: operator does not exist: boolean == boolean
HINT: No operator matches the given name and argument type(s). You may
need to add explicit type casts.
CONTEXT: SQL statement "SELECT (( $1 == true) && ( $2 == true))"
PL/pgSQL function "trigger_insert_update_registration_and_attendance"
line 13 at if

What is wrong with my syntax above?

Ferindo

--
Ferindo Middleton
Chief Architect
Sleekcollar.com

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message John DeSoi 2005-08-07 03:18:20 Re: incorrect syntax for 'plpgsql' function to test boolean values
Previous Message Frank Finner 2005-08-06 21:34:18 Re: Caracter é