mercredi 30 mai 2018

Can I use a IF statement for Accept command

I would like to know if you can put an IF statement before DECLARE, where you can declare the input variables with the ACCEPT statement EX

basic example.

ACCEPT V_epno PROMPT 'Enter employee name: '
DECLARE
     v_cepno CHAR(20);
BEGIN
     SELECT cepno INTO v_cepno 
            FROM employee
     WHERE cepno = '&V_epno ';
END;

I want something like this

ACCEPT V_epno PROMPT 'Enter employee name: '
IF '&v_epno' = 'john' then
  ACCEPT V_epsu PROMPT 'Enter employee surname: '
END IF;
DECLARE
     v_cepno CHAR(20);
     v_cepsu CHAR(20);
BEGIN
     SELECT cepsu INTO v_cepsu 
            FROM employee
     WHERE cepno = '&V_epno'
      and cepsu = '&V_epsu';
END;

but if I run this example, the program skips the if statement.

Aucun commentaire:

Enregistrer un commentaire