[Pgsql-ayuda] ¿Que_me_esta_diciendo_este_mensaje_de_error?

Gladys Arias gariaso@yahoo.com
Fri, 4 Apr 2003 17:20:17 +0200 (CEST)


--0-560578525-1049469617=:17723
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


De acuerdo a lo que dice el manual:http://www.postgresql.org/docs/view.php?version=7.3&idoc=1&file=plpgsql-structure.html

It is important not to confuse the use of BEGIN/END for grouping statements in PL/pgSQL with the database commands for transaction control. PL/pgSQL's BEGIN/END are only for grouping; they do not start or end a transaction. Functions and trigger procedures are always executed within a transaction established by an outer query --- they cannot start or commit transactions, since PostgreSQL does not have nested transactions. 

No puedes realizar commit dentro de una función pl/pgsql, toda la función es considerada una transacción. Tendrías que hacer el commit fuera, después de la llamada a la función.

Saludos, Gladys.

 

 Angel Vicente Perez <angel.vicente@knipping.es> wrote:
Hola tengo una funcion que cuando ejecuta me devuelve un mensaje de error,
del que he estado buscando referencias, y no he encontrado nada.
La funcion es :
DECLARE 
Periodov INTEGER;
Familiav CHAR(2);
NewFecha DATE;
NewIntervalo interval;
Cadena varchar(10);
BEGIN
SELECT "Familia" INTO Familiav FROM "Instrumentos" WHERE "Codigo" =
$1;
SELECT * INTO Periodov FROM "GetPeriodoCal"(Familiav);
INSERT INTO "ResultadosH" ("Codigo", "Fecha", "Verificado",
"Resultado", "Desviacion", "Observaciones") VALUES ($1, $2, $3, $4, $5, $6);
Cadena := to_char(Periodov,''999'');
NewIntervalo := Cadena || ''months'';
NewFecha := $2 + NewIntervalo;
UPDATE "Instrumentos" SET "UltCalibracion" = $2, "ProxCalibracion" =
NewFecha;
COMMIT;
RETURN 1;
END

El lenguaje es plpgsql, y el mensaje de error es
ERROR: SPI_prepare() failed on "COMMIT". Evidentemente hay algo mal hecho.
Si quito el COMMIT, no tengo mensaje de error pero tampoco tengo escrituras.
Pareciera que no quiere o no puede hacer COMMIT, pero tampoco se porque.

_______________________________________________
Pgsql-ayuda mailing list
Pgsql-ayuda@tlali.iztacala.unam.mx
http://tlali.iztacala.unam.mx/mailman/listinfo/pgsql-ayuda

---------------------------------
Yahoo! Messenger
Nueva versi&oacute;n: Super Webcam, voz, caritas animadas, y m&aacute;s #161;Gratis!
--0-560578525-1049469617=:17723
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<P>De acuerdo a lo que dice el manual:http://www.postgresql.org/docs/view.php?version=7.3&amp;idoc=1&amp;file=plpgsql-structure.html</P>
<P>It is important not to confuse the use of BEGIN/END for grouping statements in PL/pgSQL with the database commands for transaction control. PL/pgSQL's BEGIN/END are only for grouping; they do not start or end a transaction. Functions and trigger procedures are always executed within a transaction established by an outer query --- they cannot start or commit transactions, since PostgreSQL does not have nested transactions. </P>
<P>No puedes realizar commit dentro de una función pl/pgsql, toda la función es considerada una transacción. Tendrías que hacer el commit fuera, después de la llamada a la función.</P>
<P>Saludos, Gladys.</P><FONT face=Arial size=2>
<P>&nbsp;</P>
<P></FONT>&nbsp;<B><I>Angel Vicente Perez &lt;angel.vicente@knipping.es&gt;</I></B> wrote:</P>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">Hola tengo una funcion que cuando ejecuta me devuelve un mensaje de error,<BR>del que he estado buscando referencias, y no he encontrado nada.<BR>La funcion es :<BR>DECLARE <BR>Periodov INTEGER;<BR>Familiav CHAR(2);<BR>NewFecha DATE;<BR>NewIntervalo interval;<BR>Cadena varchar(10);<BR>BEGIN<BR>SELECT "Familia" INTO Familiav FROM "Instrumentos" WHERE "Codigo" =<BR>$1;<BR>SELECT * INTO Periodov FROM "GetPeriodoCal"(Familiav);<BR>INSERT INTO "ResultadosH" ("Codigo", "Fecha", "Verificado",<BR>"Resultado", "Desviacion", "Observaciones") VALUES ($1, $2, $3, $4, $5, $6);<BR>Cadena := to_char(Periodov,''999'');<BR>NewIntervalo := Cadena || ''months'';<BR>NewFecha := $2 + NewIntervalo;<BR>UPDATE "Instrumentos" SET "UltCalibracion" = $2, "ProxCalibracion" =<BR>NewFecha;<BR>COMMIT;<BR>RETURN 1;<BR>END<BR><BR>El lenguaje es plpgsql, y el mensaje de error es<BR>ERROR: SPI_prepare() failed on "COMMIT". Evidentemente hay algo mal hecho.<BR>Si quito el COMMIT, no tengo mensaje de error pero tampoco tengo escrituras.<BR>Pareciera que no quiere o no puede hacer COMMIT, pero tampoco se porque.<BR><BR>_______________________________________________<BR>Pgsql-ayuda mailing list<BR>Pgsql-ayuda@tlali.iztacala.unam.mx<BR>http://tlali.iztacala.unam.mx/mailman/listinfo/pgsql-ayuda</BLOCKQUOTE><p><hr size=1><font face="Arial" size="-1" color="#FF8000"><b>Yahoo! Messenger</b></font><br><font face="Arial" size="-1" color="black"><a href=http://es.rd.yahoo.com/mail_es/tagline/messenger/*http://es.messenger.yahoo.com/><b>Nueva versi&oacute;n</b></a>: Super Webcam, voz, caritas animadas, y m&aacute;s &#161;Gratis!</font>
--0-560578525-1049469617=:17723--