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.

Using the %ROWTYPE Attribute


DECLARE

-- %ROWTYPE can include all the columns in a table...

emp_rec employees%ROWTYPE;

-- ...or a subset of the columns, based on a cursor.

CURSOR c1 IS

SELECT department_id,

department_name

FROM departments;

dept_rec c1%ROWTYPE;

-- Could even make a %ROWTYPE with columns from multiple tables.

CURSOR c2 IS

SELECT employee_id,

email,

employees.manager_id,

location_id

FROM employees,

departments

WHERE employees.department_id = departments.department_id;

join_rec c2%ROWTYPE;

BEGIN

-- We know EMP_REC can hold a row from the EMPLOYEES table.

SELECT *

INTO emp_rec

FROM employees

WHERE ROWNUM < 2;



-- We can refer to the fields of EMP_REC using column names

-- from the EMPLOYEES table.

IF emp_rec.department_id = 20

AND emp_rec.last_name = 'JOHNSON' THEN

emp_rec.salary := emp_rec.salary * 1.15;

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