Agora faça isso dentro da pl_pgsql !

JotaComm wrote:
> 
> Olá,
> 
> Como assim não funciona?
> 
> BEGIN;
> CREATE TABLE foo(foo int);
> INSERT INTO foo VALUES(1);
> INSERT INTO foo VALUES(2);
> INSERT INTO foo VALUES(3);
> SAVEPOINT meu_ponto_de_salvamento;
> INSERT INTO foo VALUES(4);
> INSERT INTO foo VALUES(5);
> INSERT INTO foo VALUES(6);
> ROLLBACK TO SAVEPOINT meu_ponto_de_salvamento;
> COMMIT;
> 
> Ao fazer SELECT * FROM foo; devem aparecer os registros 1, 2 e 3.
> 
> []s
> 
> 2009/3/6 mateusgra <[email protected]>:
>>
>> Mas o SAVEPOINT tb não funciona.
>>
>>
>> Osvaldo Kussama wrote:
>>>
>>> 2009/3/6 Osvaldo Kussama <[email protected]>:
>>>> 2009/3/6 mateusgra <[email protected]>:
>>>>>
>>>>> Qdo executo um commit dentro de uma função em pl_pgsql gera o seguinte
>>>>> erro:
>>>>>
>>>>> SPI_execute_plan failed executing query "commit":
>>>>> SPI_ERROR_TRANSACTION
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Erro-commit-dentro-da-pl_pgsql-tp22371981p22371981.html
>>>>> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>>>>>
>>>>
>>>>
>>>> Uma função é executada sempre como uma transação e o PostgreSQL não
>>>> trabalha, pelo menos por enquanto, com transações aninhadas.
>>>>
>>>
>>>
>>> Só para complementar (não sei se se aplica a seu caso):
>>> Existe o recurso SAVEPOINT que permite uma execução seletiva de
>>> trechos de uma função:
>>> http://www.postgresql.org/docs/current/interactive/sql-savepoint.html
>>>
>>> Osvaldo
>>> _______________________________________________
>>> pgbr-geral mailing list
>>> [email protected]
>>> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Erro-commit-dentro-da-pl_pgsql-tp22371981p22372515.html
>> Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> pgbr-geral mailing list
>> [email protected]
>> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
>>
> 
> 
> 
> -- 
> JotaComm
> http://jotacomm.wordpress.com
> http://www.dextra.com.br/Postgres
> _______________________________________________
> pgbr-geral mailing list
> [email protected]
> https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Erro-commit-dentro-da-pl_pgsql-tp22371981p22372813.html
Sent from the PostgreSQL - Brasil mailing list archive at Nabble.com.

_______________________________________________
pgbr-geral mailing list
[email protected]
https://listas.postgresql.org.br/cgi-bin/mailman/listinfo/pgbr-geral

Responder a