| From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
|---|---|
| To: | Gabriel Ferro <gabrielrferro(at)yahoo(dot)com(dot)ar> |
| Cc: | pgsql-es-ayuda(at)postgresql(dot)org |
| Subject: | Re: Problema con funcion |
| Date: | 2007-01-12 01:23:15 |
| Message-ID: | 20070112012315.GO10464@alvh.no-ip.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-es-ayuda |
Gabriel Ferro escribió:
> CREATE OR REPLACE FUNCTION pasatabla(char(10))
> RETURNS void AS
> $BODY$
> DECLARE CAMPO CHAR(10);
> CADENA bytea;
> registro basura;
> BEGIN
> for registro IN SELECT "Sumario" as Sumari, "TipoInfo" as TInfo, "Info" as Infi FROM "Recibidas" loop
> cadena=ByteaText(decrypt(Infi,$1,'bf'));
> insert into "Recibidas2" ("Sumario","TipoInfo","Info") values (Sumari, TInfo,cadena);
> end loop;
> END;$BODY$
> LANGUAGE 'plpgsql' VOLATILE;
Parece una manera torpe de hacerlo. Yo te recomendaria algo como
insert into recibidas2
select sumari, tinfo, ByteaText(decrypt(infi, 'la-clave', 'bf'))
from recibidas;
Ciertamente no necesitas un SP para hacer esto.
Y en realidad tampoco necesitas ByteaText. Puedes hacerlo asi:
insert into recibidas2
select sumari, tinfo, textout(byteain(decrypt(infi, 'la-clave', 'bf')))
from recibidas;
o algo similar (quizas inverti el orden de textout() y byteain(), o
quizas incluso deberia ser textin() y byteaout()).
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jaime Casanova | 2007-01-12 02:12:18 | Re: Trigger no funciona, una ayuda por favor |
| Previous Message | Alvaro Herrera | 2007-01-12 01:16:18 | Re: Permisos! |