pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedincorrect syntax for 'plpgsql' function to test boolean values
3+ messages / 2 participants
[nested] [flat]
* incorrect syntax for 'plpgsql' function to test boolean values
@ 2005-08-07 02:52 Ferindo Middleton Jr <fmiddleton@verizon.net>
2005-08-07 03:18 ` Re: incorrect syntax for 'plpgsql' function to test boolean values John DeSoi <desoi@pgedit.com>
0 siblings, 1 reply; 3+ messages in thread
From: Ferindo Middleton Jr @ 2005-08-07 02:52 UTC (permalink / raw)
To: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: incorrect syntax for 'plpgsql' function to test boolean values
2005-08-07 02:52 incorrect syntax for 'plpgsql' function to test boolean values Ferindo Middleton Jr <fmiddleton@verizon.net>
@ 2005-08-07 03:18 ` John DeSoi <desoi@pgedit.com>
2005-08-07 05:25 ` Re: incorrect syntax for 'plpgsql' function to test boolean Ferindo Middleton Jr <fmiddleton@verizon.net>
0 siblings, 1 reply; 3+ messages in thread
From: John DeSoi @ 2005-08-07 03:18 UTC (permalink / raw)
To: fmiddleton@verizon.net; +Cc: pgsql-sql
On Aug 6, 2005, at 10:52 PM, Ferindo Middleton Jr wrote:
> 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?
>
Too much C programming :). You just want a single equal sign.
select true = true;
?column?
----------
t
(1 row)
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: incorrect syntax for 'plpgsql' function to test boolean
2005-08-07 02:52 incorrect syntax for 'plpgsql' function to test boolean values Ferindo Middleton Jr <fmiddleton@verizon.net>
2005-08-07 03:18 ` Re: incorrect syntax for 'plpgsql' function to test boolean values John DeSoi <desoi@pgedit.com>
@ 2005-08-07 05:25 ` Ferindo Middleton Jr <fmiddleton@verizon.net>
0 siblings, 0 replies; 3+ messages in thread
From: Ferindo Middleton Jr @ 2005-08-07 05:25 UTC (permalink / raw)
To: John DeSoi <desoi@pgedit.com>; +Cc: pgsql-sql
Yeah, I guess so..... I just didn't want the compiler to think I was
trying to assign the value..... And I also figured out that instead of
the &&, I needed to just say AND.... Thanks.
Ferindo
John DeSoi wrote:
>
> On Aug 6, 2005, at 10:52 PM, Ferindo Middleton Jr wrote:
>
>> 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?
>>
>
> Too much C programming :). You just want a single equal sign.
>
> select true = true;
> ?column?
> ----------
> t
> (1 row)
>
>
>
>
> John DeSoi, Ph.D.
> http://pgedit.com/
> Power Tools for PostgreSQL
>
>
--
Ferindo Middleton
Chief Architect
Sleekcollar.com
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2005-08-07 05:25 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-08-07 02:52 incorrect syntax for 'plpgsql' function to test boolean values Ferindo Middleton Jr <fmiddleton@verizon.net>
2005-08-07 03:18 ` John DeSoi <desoi@pgedit.com>
2005-08-07 05:25 ` Re: incorrect syntax for 'plpgsql' function to test boolean Ferindo Middleton Jr <fmiddleton@verizon.net>
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