sasfvs icon

Untitled

sasfvs | PRO | 07/05/17 07:02:46 AM UTC | 0 ⭐ | 7179 👁️ | Never ⏰ | []
PL/SQL |

730 B

|

None

|

0 👍

/

0 👎

SET SERVEROUTPUT  ON; 
DECLARE
    v_salary NUMBER(8); -- i have made a mistake here before
BEGIN
    SELECT salary INTO v_salary FROM employees 
    WHERE employee_id = 100;
    DBMS_OUTPUT.PUT_LINE(v_salary);
END;
/ -- this ends your block and allows you to make a new one
DECLARE
    v_salary NUMBER(8); 
    v_fname VARCHAR2(20); -- every time you have to be sure that the types of variables match the type of columns from the database.
BEGIN
    SELECT salary, first_name INTO v_salary, v_fname FROM employees  -- same logic but if I select 2 values I also have to put them in 2 diffrent variables
    WHERE employee_id = 100;
    DBMS_OUTPUT.PUT_LINE(v_fname ||' has '||v_salary||' euros.'); -- Example: Victor has 2500 euros. (this will be the output)
END;

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎