sasfvs

Untitled

Jul 5th, 2017
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.73 KB | None | 0 0
  1. SET SERVEROUTPUT  ON;
  2. DECLARE
  3.     v_salary NUMBER(8); -- i have made a mistake here before
  4. BEGIN
  5.     SELECT salary INTO v_salary FROM employees
  6.     WHERE employee_id = 100;
  7.     DBMS_OUTPUT.PUT_LINE(v_salary);
  8. END;
  9. / -- this ends your block and allows you to make a new one
  10. DECLARE
  11.     v_salary NUMBER(8);
  12.     v_fname VARCHAR2(20); -- every time you have to be sure that the types of variables match the type of columns from the database.
  13. BEGIN
  14.     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
  15.     WHERE employee_id = 100;
  16.     DBMS_OUTPUT.PUT_LINE(v_fname ||' has '||v_salary||' euros.'); -- Example: Victor has 2500 euros. (this will be the output)
  17. END;
Advertisement