
مساعدة فى حل اسئلة pl-sql
#1
تاريخ المشاركة 08 May 2010 - 02:02 PM
-Create pL\sql block to declare a cursor EMP_CUR to select the employee_id , first_name,last_name,Salary,hire_date.for all employees works in any department that is name start with ‘c’.process each row from the cursor, and if the salary greater than 15000 and hire_date is greater than 01-feb-1988 display the last_ name salary and hire_date.
2create pL\sql block to declare a cursor date_cur to select the employee_id, first_name,last_name,salary for employees whose hire_date is less than 01-mar-2000,Process each row from the cursor and if the salary is less than or equal 15000.rais an exception .handle the exception with appropriate exception handler thatinsert values into error_table: employee_id,salary.otherwise display “thank you for your effort”.
0
#2
تاريخ المشاركة 08 May 2010 - 03:07 PM
حل السؤال الأول
declare cursor EMP_CUR is select e.employee_id as employee_id , e.first_name as first_name , e.last_name as last_name, e.Salary as Salary, e.hire_date as hire_date, d.department_no from empolyees e, departments d where e.department_no = d.department_no and d.department_name like 'c%'; begin for rec_1 in emp_cur loop if rec_1.salary > 15000 and rec_1.hire_date > to_date('01-feb-1988','dd-mon-yyyy') then dbms_output.put_line (' Last Name ' || rec_1.last_name || ' Salary ' || rec_1.salary || ' Hire Date ' || rec_1.hire_date); end if; end loop; end;
حل السؤال الثاني
declare salary_exp EXCEPTION; cursor EMP_CUR is select employee_id , first_name , last_name , Salary from empolyees where hire_date < to_date('01-mar-2000','dd-mon-yyyy'); begin for rec_1 in emp_cur loop if rec_1.salary <= 15000 then RAISE salary_exp; else dbms_output.put_line ('thank you for your effort'); end if; end loop; EXCEPTION WHEN salary_exp THEN insert into error_table (employee_id,salary) values (rec_1.employee_id, rec_1.salary); commit; end;
تم التعديل بواسطة ahasan, 08 May 2010 - 03:12 PM.
لا إله إلا انت سبحانـــك ... إني كنت من الظالمين
كن كما يريــــــــد الله ... يكن لك فوق ما تريـــــد
#4
تاريخ المشاركة 08 May 2010 - 03:47 PM
مششكوووور كتتتتير اخوي
بس بدي اسال انتى متأكد من الجابة لانه كتير مهم في عندي سؤال تاني عادي اسألك اياه
يعطييييك الف عافية وما قصرت
ان شاء الله أخوي
لكن .. طبقها انت واتأكد بنفسك ... عشان تتقن كتابة الاكواد

واسال اخوي .. وان شاء الله اذا قدرت اساعدك ما بقصر معك

لا إله إلا انت سبحانـــك ... إني كنت من الظالمين
كن كما يريــــــــد الله ... يكن لك فوق ما تريـــــد
#6
تاريخ المشاركة 08 May 2010 - 04:27 PM
اخوووي ... انا ان شاء الله رح احل السؤال ... بس بتمنى منك انت تحاول عشان تتقن كتابة الكود
declare v_count number; begin select count(1) into v_count from from employees where department_id = 30; dbms_output.put_line ('The number of employees who work in department_id=30 ' || v_count); exception when no_data_found then null; end;
بالتوفيق
لا إله إلا انت سبحانـــك ... إني كنت من الظالمين
كن كما يريــــــــد الله ... يكن لك فوق ما تريـــــد