Estou migrando o DB de SQL Server para Postgre, e estou tendo dificuldades na
converão de algumas Store Procedures que utilizam Cursor.
Como posso percorrer todo o cursor, registro por registro?
Exemplo de como seria um Script no SQL Server que gostaria de converter.
"
CREATE PROCEDURE spTeste (@Campo int) AS
Begin
declare @Codigo int, @Nome varchar(100), @i int
declare NomeCursor cursor for
select Codigo, Nome from Clientes order by Nome
open NomeCursor
fetch NomeCursor into @Codigo, @Nome
Set @i = 0
WHILE @@FETCH_STATUS = 0
BEGIN
set @i = @i + 1
update Clientes set @Campo = @i where Codigo = @Codigo
fetch NomeCursor into @Codigo, @Nome
end
CLOSE NomeCursor
DEALLOCATE NomeCursor
End
" 
-- 
View this message in context: 
http://www.nabble.com/SQL-Server--%3E-Postgre-tp26094654p26094654.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