vendredi 8 janvier 2016

IF-ELSE statement: create a column depending on another one

In the table JAN07, I have a column TEMPO_INTERCORSO (number(10,0)) and I want to create another column ANTE_POST (number(1)) that is '0' when TEMPO_INTERCORSO > 0 and '1' otherwise.

IF (TEMPO_INTERCORSO > 0) THEN
   UPDATE JAN07 SET ANTE_POST = 1
ELSE
   UPDATE JAN07 SET ANTE_POST = 0
END IF;

I've tried a lot of different ways that you can find on the web (for example the ";" before the ELSE: sometimes there is, sometimes not), but it is still not working.

IF (TEMPO_INTERCORSO = 0) THEN
Report error -
Comando sconosciuto

Some ideas?

ps= I've tried with JAN07.TEMPO_INTERCORSO too!

Aucun commentaire:

Enregistrer un commentaire