From: | "Rafael Montoya" <rafo-mm(at)hotmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | [General] Using cursors... |
Date: | 2005-10-07 15:52:02 |
Message-ID: | BAY18-F791F195C5937EA40A8F47F8840@phx.gbl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi everybody, thanks for your answers about hardware requirements. DB design
was succesful and now we are migrating stored procedures from oracle to
PostgreSQL.
I can't handle cursors very well in PostgreSQL, for example, i need to
migrate this stored procedure:
CREATE OR REPLACE PROCEDURE LOAD_EXP AS
cursor c_exp IS
select C_COD_PRE from temp_codpre;
BEGIN
for cur1 in c_exp loop
update lcmap_ctrcre
set v_cod_pcar = '07'
where c_num_exp = cur1.C_COD_PRE;
commit;
end loop;
end LOAD_EXP;
/
and what i did in PostgreSQL was:
CREATE OR REPLACE FUNCTION LOAD_EXP() RETURNS VOID AS $$
DECLARE
c_exp refcursor;
BEGIN
open c_exp for select C_COD_PRE from temp_codpre;
loop
FETCH c_exp INTO VARIABLE
IF NOT FOUND THEN
EXIT;
END IF;
update lcmap_ctrcre
set v_cod_pcar = '07'
where c_num_exp = cur1.C_COD_PRE;
end loop;
close c_exp;
END;
$$ LANGUAGE plpgsql;
select LOAD_EXP()
My really big doubt is about what VARIABLE must be and if this function is
efficient how is it written.
I'll appreciate any advice.
Rafael
_________________________________________________________________
Acepta el reto MSN Premium: Correos más divertidos con fotos y textos
increíbles en MSN Premium. Descárgalo y pruébalo 2 meses gratis.
http://join.msn.com?XAPID=1697&DI=1055&HL=Footer_mailsenviados_correosmasdivertidos
From | Date | Subject | |
---|---|---|---|
Next Message | Andrus | 2005-10-07 16:00:27 | Re: PostgreSQL 8.1 vs. MySQL 5.0? |
Previous Message | David Fetter | 2005-10-07 15:47:52 | Re: PostgreSQL 8.1 vs. MySQL 5.0? |