From: Ferindo Middleton Jr <fmiddleton@verizon.net>
To: pgsql-sql@postgresql.org
Subject: incorrect syntax for 'plpgsql' function to test boolean values
Date: Sat, 06 Aug 2005 22:52:24 -0400
Message-ID: <42F57768.6090702@verizon.net> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: fmiddleton@verizon.net
Subject: Re: incorrect syntax for 'plpgsql' function to test boolean values
In-Reply-To: <42F57768.6090702@verizon.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox