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 4915FD1B298 for ; Tue, 20 Jul 2004 15:25:01 -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 55766-04 for ; Tue, 20 Jul 2004 18:24:58 +0000 (GMT) Received: from FW01.powerupnetworks.com (fw01.powerupnetworks.com [67.95.85.164]) by svr1.postgresql.org (Postfix) with ESMTP id 7EB90D1B16E for ; Tue, 20 Jul 2004 15:24:56 -0300 (ADT) Received: from hermes.internal.powerupnetworks.com ([192.168.21.6]) by FW01.powerupnetworks.com (8.12.9/8.11.6) with ESMTP id i6KHfNMM001080 for ; Tue, 20 Jul 2004 12:41:23 -0500 X-MimeOLE: Produced By Microsoft Exchange V6.0.6556.0 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Subject: fail to compare between bytea output in plpgsql Date: Tue, 20 Jul 2004 13:24:57 -0500 Message-ID: <3AE153EDD5CA7B4CBA26FCDA1CBA6478403422@hermes.internal.powerupnetworks.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: fail to compare between bytea output in plpgsql thread-index: AcRuhtyUxHypGEzdSeCWQ2ACjYZTmA== From: "Peter Wang" To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/130 X-Sequence-Number: 18382 I have a function and am using cursor. All the columns I select in the curs= or clause are BYTEA datatype. I need to compare the after-fetch-value for two BYTEA columns which is temp= 2 and temp3 shown as below.=20 I don't think I can compare it because there is no record in temp table whi= ch I use for debug purpose. Does anyone know how to compare the after-fetched-value for two BYTEA data= type in pgsql's function?=20 CREATE OR REPLACE FUNCTION pa_revision(INT4, INT4) RETURNS INTEGER AS ' DECLARE i_ages ALIAS FOR $1; i_devs ALIAS FOR $2; cur1 CURSOR FOR SELECT a.device_id, a.baseline_revision_id, b.revision_id, b.operational_de= vice_id <<--------- All BYTEA datatype FROM cm_device a, cm_revision b WHERE a.device_id =3D b.operational_device_id AND current_date - b.creation_date > i_ages; temp1 cm_device.device_id%TYPE; temp2 cm_device.baseline_revision_id%TYPE; temp3 cm_revision.revision_id%TYPE; temp4 cm_revision.operational_device_id%TYPE; temp5 INT4; BEGIN OPEN cur1; LOOP FETCH cur1 INTO temp1, temp2, temp3, temp4; IF NOT FOUND THEN RETURN 1; END IF; IF temp2 <> temp3 THEN <<-------------------------------- How can I compa= re the value of BYTEA datatype ? SELECT count(*) INTO temp5 FROM cm_revision WHERE operational_device_id =3D temp4; insert into temp values (temp5); ......... END IF; END IF; END LOOP; CLOSE cur1; RETURN 0; END; ' LANGUAGE 'plpgsql';