Hello, I have a rather simple function I’ve been using in
7.3.4
version ----------------------------------------------------------------------------------------- PostgreSQL 7.3.4
on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.2 20020927 (prerelease) (1 row) This compares an integer to all elements in an integer array
and looks for a match CREATE OR REPLACE FUNCTION
public.array_element_compare(_int4, int4) RETURNS text AS ' DECLARE a
ALIAS FOR $1; b
ALIAS FOR $2; i
integer; status
text; BEGIN i
:= 1; status
:= ‘'false’'; WHILE
a[i] IF
a[i] = b THEN status
:= ‘'true’'; END
IF; i
:= i+1; END
RETURN
status; END;' LANGUAGE
'plpgsql'; It works find germinate1.5 =# select array_element_compare('{100,92,82}',
82); array_element_compare ----------------------- true (1 row) germinate1.5 =# select array_element_compare('{100,92}',
82); array_element_compare ----------------------- false (1 row) I’m now testing our database on 7.4 and get an error
with this function and I can’t figure out how to fix it.
version ------------------------------------------------------------------------------------- PostgreSQL 7.4
on i686-pc-cygwin, compiled by GCC gcc (GCC) 3.3.1 (cygming special) (1 row) germinate1.5 =# select array_element_compare('{100, 92,
82}', 82); ERROR: invalid
input syntax for type boolean: "100" CONTEXT:
PL/pgSQL function "array_element_compare" line 9 at while Can anyone point me in the right direction? Thanks much for any help, Jennifer ***************************************************************************************** DISCLAIMER: This email is from the Scottish Crop Research Institute, but the views expressed by the sender are not necessarily the views of SCRI and its subsidiaries. This email and any files transmitted with it are confidential to the intended recipient at the e-mail address to which it has been addressed. It may not be disclosed or used by any other than that addressee. Although SCRI has taken reasonable precautions to ensure no viruses are present in this email, neither the Institute nor the sender accepts any responsibility for any viruses, and it is your responsibility to scan the email and the attachments (if any). |