incorrect syntax for 'plpgsql' function to test boolean values - Mailing list pgsql-sql

From Ferindo Middleton Jr
Subject incorrect syntax for 'plpgsql' function to test boolean values
Date
Msg-id 42F57768.6090702@verizon.net
Whole thread Raw
Responses Re: incorrect syntax for 'plpgsql' function to test boolean values
List 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



pgsql-sql by date:

Previous
From: Frank Finner
Date:
Subject: Re: Caracter é
Next
From: John DeSoi
Date:
Subject: Re: incorrect syntax for 'plpgsql' function to test boolean values