Live ORACLE

if you are Oracle Developer ,than this Blog most likely will make you happy.

About my Blog

This Blog particularized for Oracle Developers ... you will see interesting Codes for SQL , PL/SQL as well as new ideas for Developer Suite and Client Tools that will help you in your professional life ... and I hope I reach for your satisfaction.

About Me

I'm Hany Freedom , 25 years old , I live in EL-Minia City in Egypt , I'm Moderator at ArabOUG.org the best Arabic Forum for ORACLE on the Net. if you interested to know more about me .... just Click Here.

Passing Parameters to Explicit Cursors


DECLARE

emp_job employees.job_id%TYPE := 'ST_CLERK';

emp_salary employees.salary%TYPE := 3000;

my_record employees%ROWTYPE;

CURSOR c1(job VARCHAR2,

max_wage NUMBER) IS

SELECT *

FROM employees

WHERE job_id = job

AND salary > max_wage;

BEGIN

-- Any of the following statements opens the cursor:

-- OPEN c1('ST_CLERK', 3000); OPEN c1('ST_CLERK', emp_salary);

-- OPEN c1(emp_job, 3000); OPEN c1(emp_job, emp_salary);

OPEN c1(emp_job,emp_salary);



LOOP

FETCH c1 INTO my_record;



EXIT WHEN c1%NOTFOUND;



-- process data record

dbms_output.Put_line('Name = '

||my_record.last_name

||', salary = '

||my_record.salary

||', Job Id = '

||my_record.job_id);

END LOOP;

END;

/




Output :-

Name = Nayer, salary = 3200, Job Id = ST_CLERK
Name = Bissot, salary = 3300, Job Id = ST_CLERK
Name = Mallin, salary = 3300, Job Id = ST_CLERK
Name = Ladwig, salary = 3600, Job Id = ST_CLERK
Name = Stiles, salary = 3200, Job Id = ST_CLERK
Name = Rajs, salary = 3500, Job Id = ST_CLERK
Name = Davies, salary = 3100, Job Id = ST_CLERK

PL/SQL procedure successfully completed.

Share/Save/Bookmark

0 comments:

Post a Comment



Newer Posts Older Posts Home Page
 
http://www.dpriver.com/images/sqlpp-banner-2.png

Thanks for reading my Blog ... you Visitor Number :-