Program using cursor for updating salary of employee did rob pattinson really dating nikki reed
INSERT INTO EMPLOYEES (EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL, PHONE_NUMBER, HIRE_DATE, JOB_ID, SALARY, DEPARTMENT_ID) VALUES (207, 'ANGELA', 'SNYDER','ANGELA','2', SYSDATE, 'SA_MAN', 12000, 80) SELECT JOB_TITLE, DEPARTMENT_NAME, LAST_NAME, START_DATE FROM JOB_HISTORY JOIN JOBS USING (JOB_ID) JOIN DEPARTMENTS USING (DEPARTMENT_ID) JOIN EMPLOYEES USING (EMPLOYEE_ID) WHERE TO_CHAR(START_DATE,'YYYY') BETWEEN 20 SELECT TO_CHAR(HIRE_DATE,'MON-YY') FROM EMPLOYEES JOIN DEPARTMENTS USING (DEPARTMENT_ID) JOIN LOCATIONS USING (LOCATION_ID) WHERE CITY = 'Seattle' GROUP BY TO_CHAR(HIRE_DATE,'MON-YY') HAVING COUNT(*) SELECT COUNTRY_NAME, CITY, COUNT(DEPARTMENT_ID) FROM COUNTRIES JOIN LOCATIONS USING (COUNTRY_ID) JOIN DEPARTMENTS USING (LOCATION_ID) WHERE DEPARTMENT_ID IN (SELECT DEPARTMENT_ID FROM EMPLOYEES GROUP BY DEPARTMENT_ID HAVING COUNT(DEPARTMENT_ID) Declare V_salary_120 employees.salary%type; Begin Select salary into v_salary_120 From employees where employee_id = 120; Update employees set salary = ( select salary from employees where employee_id = 122) Where employee_id = 120; Update employees set salary = v_salary_120 Where employee_id = 122; Commit; End; declare v_salary employees.salary%type; v_exp number(2); v_cp number(5,2); begin select v_salary, floor ( (sysdate-hire_date)/365) into v_salary, v_exp from employees where employee_id = 150; if v_salary declare v_name employees.first_name%type; v_deptname departments.department_name%type; begin select first_name , department_name into v_name, v_deptname from employees join departments using (department_id) where employee_id = ( select manager_id from employees where employee_id = 103); dbms_output.put_line(v_name); dbms_output.put_line(v_deptname); end; declare v_min number(3); v_max number(3); v_c number(1); begin select min(employee_id), max(employee_id) into v_min, v_max from employees; for i in v_min 1 ..v_max - 1 loop select count(*) into v_c from employees where employee_id = i; if v_c = 0 then dbms_output.put_line(i); end if; end loop; end; declare v_year number(4); v_c number(2); begin select to_char(hire_date,'yyyy') into v_year from employees group by to_char(hire_date,'yyyy') having count(*) = ( select max( count(*)) from employees group by to_char(hire_date,'yyyy')); dbms_output.put_line('Year : '
What I have not learned how to do is to update a single record that was read through a cursor.
SQL provides a special phrase, CURRENT OF, which you place in the WHERE clause.
The words CURRENT OF, followed by the cursor name, refer to the last row that was retrieved through the cursor with the FETCH command. The set-at-a-time update to which you referred is called a searched update.
Because only one exception can be raised at a time in a session, it doesn’t make any sense to allow you to check for two (or more) exceptions in a single handler.
For full explanations of both of these answers, visit plsqlchallenge.com, register or log in, and click the Closed/Taken tab in Play a Quiz.
It’s rare, in fact, that the data with which you are working is just a single value, so records and other composite datatypes are likely to figure prominently in your PL/SQL programs.