X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 0626B52BBC for ; Sat, 6 Aug 2005 23:51:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58732-03 for ; Sun, 7 Aug 2005 02:51:28 +0000 (GMT) Received: from vms042pub.verizon.net (vms042pub.verizon.net [206.46.252.42]) by svr1.postgresql.org (Postfix) with ESMTP id BA2A152BA9 for ; Sat, 6 Aug 2005 23:51:27 -0300 (ADT) Received: from [192.168.1.13] ([68.239.97.180]) by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IKT00812ZXJIJA1@vms042.mailsrvcs.net> for pgsql-sql@postgresql.org; Sat, 06 Aug 2005 21:51:31 -0500 (CDT) Date: Sat, 06 Aug 2005 22:52:24 -0400 From: Ferindo Middleton Jr Subject: incorrect syntax for 'plpgsql' function to test boolean values To: pgsql-sql@postgresql.org Reply-To: fmiddleton@verizon.net Message-id: <42F57768.6090702@verizon.net> Organization: Sleek Collar MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.6 (Windows/20050716) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.75 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST X-Spam-Level: * X-Archive-Number: 200508/36 X-Sequence-Number: 22264 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