Re: cursors in postgres

From: A(dot)M(dot) <agentm(at)themactionfaction(dot)com>
To: pgsql-general general <pgsql-general(at)postgresql(dot)org>
Subject: Re: cursors in postgres
Date: 2007-03-29 17:04:58
Message-ID: 7237616E-84F3-47AE-9D36-3CAAC9D87416@themactionfaction.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Mar 29, 2007, at 10:47 , Jasbinder Singh Bali wrote:

> Hi,
> I've written a function using cursors as follows:
> can anyone please comment on the text in red.
>
>
> ------------------------------------------------------
>
> CREATE OR REPLACE FUNCTION sp_insert_tbl_email_address(int4, text,
> text, text)
> RETURNS void AS
> $BODY$
> DECLARE
> uid int4 ;
> src text;
> local text;
> domain text;
> cur_dup_check CURSOR FOR SELECT * FROM tbl_email_address
> WHERE unmask_id=$1 and source=$2 and email_local=$3 and
> email_domain=$4;
>
>
> BEGIN
>
> OPEN cur_dup_check ;
>
> FETCH cur_dup_check INTO uid,src,local,domain;
> --need to check the fetch status of the cursor whether any rows
> were returned or not and keep moving to the next record till fetch
> status is not zero

Huh? Why don't you simply declare a unique constraint across the
columns you require?

-M

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Pete 2007-03-29 17:07:42 Oracle to PSQL function
Previous Message Benjamin Arai 2007-03-29 17:02:49 Re: COPY command details