From: | Michael Dunn <michael(at)2cactus(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Testing for null value in arrays |
Date: | 2001-01-03 00:17:51 |
Message-ID: | 3A526FAF.5090902@2cactus.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
I am new to the list and somewhat new to PostgreSQL... so, if my
question seems mundane or trivial I apologize. I have a plpgsql function
that performs multiple inserts and updates on a variety of tables. In
one particular instance the function tests an array for null. If the
array is not null the record is inserted. I can get the array to test
true to null but it fails when reversed.
*** A sample and simple version of what I am trying to do ***
CREATE FUNCTION sb_event_insert (_TEXT)
RETURNS bool
AS 'DECLARE
argv_vector ALIAS FOR $1;
evnt_seq INTEGER;
BEGIN
IF argv_vector = \'{}\'
THEN
evnt_seq := nextval(\'event_sequence\');
INSERT INTO argv VALUES (evnt_seq, argv_vector);
END IF;
END;'
LANGUAGE 'plpgsql';
This evaluates successfully and without errors... but, obviously I am
testing for not null. It seems inefficient to use an IF - THEN - ELSE
statement here. So, by reversing the evaluation
IF argv_vector != \'{}\'
the function when executed fails with the following error:
SELECT sb_event_insert ('{}');
ERROR: Unable to identify an operator '<>' for types '_text' and
'unknown'. You will have to retype this query using an explicit cast.
Regards, Michael Dunn
From | Date | Subject | |
---|---|---|---|
Next Message | Artur Pietruk | 2001-01-03 00:20:43 | Re: ECPG could not connect to the database. |
Previous Message | GH | 2001-01-02 23:53:26 | Re: RE: Re: MySQL and PostgreSQL speed compare |