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
0 B
|👍
/👎
0 B
|👍
/👎