2011/3/17 izana souza torres <[email protected]> > > Sim, > Como você falou, elas podem fazer para de uma transação quando chamada dentro > de uma. > Mas teria como vc me dar um exemplo prático ? >
No PostgreSQL, quando você executa uma função, ela roda sob uma transação. Se a função tiver uma exceção não tratada, tudo que houve na função (e na transação que chamou a função) será descartado (ROLLBACK). Da documentação [1]:` "It is important not to confuse the use of BEGIN/END for grouping statements in PL/pgSQL with the similarly-named SQL commands for transaction control. PL/pgSQL'sBEGIN/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 that transaction, since there would be no context for them to execute in. However, a block containing an EXCEPTION clause effectively forms a subtransaction that can be rolled back without affecting the outer transaction. For more about that see Section 39.6.5." Para controlar erros dentro da função, você pode usar sub-blocos dentro da função, conforme descrito em [2] Ficou claro? Roberto [1] http://www.postgresql.org/docs/9.0/interactive/plpgsql-structure.html [2] http://www.postgresql.org/docs/9.0/interactive/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING _______________________________________________ pgbr-geral mailing list [email protected] https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
