How to do WHILE in PL / SQL

1

I need to make a WHILE in SQL. Follow the code I've already tried

DECLARE CONT INT;
SET CONT=0;

WHILE CONT < 3
BEGIN
SELECT CONT   
SET  CONT = CONT +1;
END;

The error that appears is as follows:

Erro a partir da linha : 1 no comando - DECLARE CONT INT; SET CONT=0;    
WHILE CONT < 3 BEGIN SELECT CONT    SET  CONT = CONT +1; END; Relatório de
erros - ORA-06550: linha 2, coluna 9: PLS-00103: Encontrado o símbolo "="
quando um dos seguintes símbolos era esperado:

  := . ( @ % ; not nulo faixa default caractere
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
    
asked by anonymous 25.10.2016 / 02:35

2 answers

0

Friend for the bug report you put you are using Oracle and its syntax is a bit different for writing a while.

Try this:

DECLARE CONT INTEGER := 0;
BEGIN
 WHILE CONT < 3 LOOP
   SET CONT := CONT + 1;
 END LOOP;
END;
    
25.10.2016 / 03:07
-1

DECLARE CONT INT; SET CONT = 0;

WHILE CONT < 3 DO BEGIN SELECT CONT
SET CONT = CONT +1; END WHILE;

In MYSQL

    
25.10.2016 / 03:28