Fórum Como transformar uma procedure do firebird para o postgresql #26727
07/05/2007
0
amigos,
tenho a seguinte procedure q uso no firebird 2.0, funciona perfeitamente, só q estou com dificuldades em migra-la para o postgresql.
tenho a seguinte procedure q uso no firebird 2.0, funciona perfeitamente, só q estou com dificuldades em migra-la para o postgresql.
CREATE PROCEDURE SP_GERA_CHAVE ( campo varchar(30)) returns ( vlr_chave numeric(6,0)) as declare variable ok integer; declare variable n_cod integer; declare variable sqlaux varchar(200); declare variable tabela varchar(40); declare variable tmp integer; begin if (:campo is null) then exit; campo = upper(:campo); ok = 0; select valor, tabela from sys_chaves where campo like :campo into :n_cod, :tabela; if (:tabela is null) then exit; tmp = null; while (ok=0) do begin n_cod = n_cod + 1; sqlaux = ´select ´ || :campo || ´ from ´ || :tabela || ´ where ´ || :campo || ´=´ || n_cod; execute statement sqlaux into :tmp; if (:tmp is null) then ok = 1; tmp = null; end update sys_chaves set valor=:n_cod where campo like :campo; vlr_chave = n_cod; suspend; end
Orlando Frade
Curtir tópico
+ 0
Responder
Clique aqui para fazer login e interagir na Comunidade :)