problema com while

Oracle

30/03/2007

gostaria de usar o while pegando um campo da tabela mas deste jeito nao funciona:

WHILE TABELA.CAMPO < 100 LOOP
INSERT INTO TABELA(CAMPO) SELECT MAX(CAMPO) + 1 FROM TABELA;
END LOOP;

ME AJUDEM...!!!


Stgmta

Stgmta

Curtidas 0

Respostas

Motta

Motta

30/03/2007

+- isto

declare
  vn number;
begin
  select max(campo) + 1
  into vn
  from tabela;
  --
  for i in 1..100 
  loop
    insert into tabela (campo) values (vn+1);
  end loop;
end; 



GOSTEI 0
Arf

Arf

30/03/2007

Mais ou menos assim:

begin
for i in ( select <campo> from <tabela> where <condição>´ ) loop
execute immediate ´insert into <tabela> ´ || i.max(campo)||´+1´;
end loop;
end;
/


PS: Código não testado.

ARF.


GOSTEI 0
Motta

Motta

30/03/2007

insert into tabela (campo) values (vn+ i );


GOSTEI 0
POSTAR