Error using Case and Select in PL-SQL

1

I have this code:

DECLARE
BEGIN

  SELECT p.categoria(
    CASE 
      WHEN p.categoria = 'A' THEN DBMS_OUTPUT.PUT_LINE('A')
      ELSE 2000 END
  )    
  FROM PRODUTO_TESTE2 p;

END;

Error message:

  

Error Reporting - ORA-06550: line 6, column 47: PL / SQL: ORA-00904:   : invalid identifier ORA-06550: line 4, column 3: PL / SQL: SQL   Statement ignored   06550. 00000 - "line% s, column% s: \ n% s"   * Cause: Usually a PL / SQL compilation error.   * Action:

Products Table Structure

    
asked by anonymous 24.01.2018 / 20:50

1 answer

6

Try to do this your select:

DECLARE
BEGIN

  SELECT p.categoria,
    CASE WHEN p.categoria = 'A' THEN DBMS_OUTPUT.PUT_LINE('A')
    ELSE 2000 END   
  FROM PRODUTO_TESTE2 p;

END;
    
26.01.2018 / 11:33