pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Wang <pwang@voyence.com>
To: pgsql-sql@postgresql.org
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> (raw)


I have a function and am using cursor. All the columns I select in the cursor clause are BYTEA datatype.

I need to compare the after-fetch-value for two BYTEA columns which is temp2 and temp3 shown as below. 
I don't think I can compare it because there is no record in temp table which I use for debug purpose.

Does anyone  know how to compare the after-fetched-value for two BYTEA datatype in pgsql's function? 



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_device_id  <<--------- All BYTEA datatype
FROM cm_device a, cm_revision b
WHERE a.device_id = 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 compare the value of BYTEA datatype ?
    SELECT count(*)
    INTO temp5
    FROM cm_revision
    WHERE operational_device_id = temp4;

 insert into temp values (temp5);
    .........
    END IF;
END IF;

END LOOP;
CLOSE cur1;
RETURN 0;
END;
' LANGUAGE 'plpgsql';




Message-ID: <3AE153EDD5CA7B4CBA26FCDA1CBA6478403422@hermes.internal.powerupnetworks.com>
Permalink:  ../3AE153EDD5CA7B4CBA26FCDA1CBA6478403422@hermes.internal.powerupnetworks.com/
Also on:    postgresql.org/message-id/3AE153EDD5CA7B4CBA26FCDA1CBA6478403422@hermes.internal.powerupnetworks.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: pwang@voyence.com
  Subject: Re: fail to compare between bytea output in plpgsql
  In-Reply-To: <3AE153EDD5CA7B4CBA26FCDA1CBA6478403422@hermes.internal.powerupnetworks.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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