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.

Assigning Values to Tables with Complex Datatypes


DECLARE

TYPE emp_name_rec IS RECORD(firstname employees.first_name%TYPE,

lastname employees.last_name%TYPE,

hiredate employees.hire_date%TYPE);

-- Table type that can hold information about employees

TYPE emplist_tab IS TABLE OF EMP_NAME_REC;

seniorsalespeople EMPLIST_TAB;

-- Declare a cursor to select a subset of columns.

CURSOR c1 IS

SELECT first_name,

last_name,

hire_date

FROM employees;

endcounter NUMBER := 10;

TYPE empcurtyp IS REF CURSOR;

emp_cv EMPCURTYP;

BEGIN

OPEN emp_cv FOR

SELECT first_name,

last_name,

hire_date

FROM employees

WHERE job_id = 'SA_REP'

ORDER BY hire_date;



FETCH emp_cv BULK COLLECT INTO seniorsalespeople;



CLOSE emp_cv;



-- for this example, display a maximum of ten employees

IF seniorsalespeople.LAST > 0 THEN

IF seniorsalespeople.LAST < 10 THEN

endcounter := seniorsalespeople.LAST;

END IF;



FOR i IN 1.. endcounter LOOP

dbms_output.Put_line(Seniorsalespeople(i).lastname

||', '

||Seniorsalespeople(i).firstname

||', '

||Seniorsalespeople(i).hiredate);

END LOOP;

END IF;

END;

/



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 :-