cursors in postgres

Поиск
Список
Период
Сортировка
От Jasbinder Singh Bali
Тема cursors in postgres
Дата
Msg-id a47902760703290747r2dc5f9a2q6b1275392f042c36@mail.gmail.com
обсуждение исходный текст
Ответы Re: cursors in postgres  ("Filip Rembiałkowski" <plk.zuber@gmail.com>)
Re: cursors in postgres  ("A.M." <agentm@themactionfaction.com>)
Re: cursors in postgres  (A.M. <agentm@themactionfaction.com>)
Список pgsql-general
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

    INSERT INTO tbl_email_address(unmask_id,source,email_local,email_domain)
    VALUES ($1,$2,$3,$4) ;
END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION sp_insert_tbl_email_address(int4, int4, text, text, text) OWNER TO postgres;


-----------------------------------------------------

Thanks,
~Jas

В списке pgsql-general по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: RES: Order by behaviour
Следующее
От: "Filip Rembiałkowski"
Дата:
Сообщение: Re: cursors in postgres