From: | Pablo Braulio <brulics(at)gmail(dot)com> |
---|---|
To: | Alvaro Herrera <alvherre(at)commandprompt(dot)com>, postgres <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Intentando hacer un insert con un trigger. |
Date: | 2008-01-17 16:33:42 |
Message-ID: | 478F8366.6040802@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Alvaro Herrera escribió:
> Pablo Braulio escribió:
>
>> create or replace function nuevogrupo() returns trigger as $$
>> declare
>> nomrecurso record;
>> begin
>> for nomrecurso in select id from recursos
>> loop
>> execute insert into permisosrecursos(recurso,grupo)
>> values(nomrecurso,new.id);
>> end loop;
>> return new;
>> end;
>
> Borra la palabra "EXECUTE" y deberia funcionar.
>
He visto el siguiente ejemplo en el manual y por eso lo había puesto.
CREATE FUNCTION cs_refresh_mviews () RETURNS INTEGER AS ’
DECLARE
mviews RECORD;
BEGIN
PERFORM cs_log(’’Refreshing materialized views...’’);
FOR mviews IN SELECT * FROM cs_materialized_views ORDER BY sort_key LOOP
-- Ahora "mviews" tiene un registro de la vista cs_materialized_views
PERFORM cs_log(’’Refreshing materialized view ’’ ||
quote_ident(mviews.mv_name) || ’’...’’);
EXECUTE ’’TRUNCATE TABLE ’’ || quote_ident(mviews.mv_name);
EXECUTE ’’INSERT INTO ’’ || quote_ident(mviews.mv_name) || ’’ ’’ ||
mviews.mv_query;
END LOOP;
PERFORM cs_log(’’Done refreshing materialized views.’’);
RETURN 1;
end;
’ LANGUAGE ’plpgsql’;
- --
< ¡¡Nos vemos!! >
----------------------------
\
\
.::!!!!!!!:.
.!!!!!:. .:!!!!!!!!!!!!
~~~~!!!!!!. .:!!!!!!!!!UWWW$$$
:$$NWX!!: .:!!!!!!XUWW$$$$$$$$$P
$$$$$##WX!: .<!!!!UW$$$$" $$$$$$$$#
$$$$$ $$$UX :!!UW$$$$$$$$$ 4$$$$$*
^$$$B $$$$\ $$$$$$$$$$$$ d$$R"
"*$bd$$$$ '*$$$$$$$$$$$o+#"
"""" """""""
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHj4NmK7lGsMchFswRAiC+AKCVj8rsWy34N6bnsSLugQhC7XH2fwCeMwSr
HMpVnHkd9YGDEhTLWvIIxAQ=
=17tf
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2008-01-17 16:46:00 | Re: Intentando hacer un insert con un trigger. |
Previous Message | Silvio Quadri | 2008-01-17 16:21:52 | Re: Intentando hacer un insert con un trigger. |