RSS

9.1.1 Make Use of Record Types

09 May

DECLARE

vr_zip ZIPCODE%ROWTYPE;

BEGIN

SELECT *

INTO vr_zip

FROM zipcode

WHERE rownum < 2;

DBMS_OUTPUT.PUT_LINE(‘City: ‘ || vr_zip.city);

DBMS_OUTPUT.PUT_LINE(‘State: ‘ || vr_zip.state);

DBMS_OUTPUT.PUT_LINE(‘ZIP: ‘ || vr_zip.zip);

END;

 

 

DECLARE

CURSOR c_student_name IS

SELECT first_name, last_name

FROM student;

vr_student_name c_student%ROWTYPE;

Record vr_student_name has a structure similar to a row returned by the SELECT statement defined in the cursor. It contains two attributes—the student’s first and last names. It is important to note that a cursor-based record can be declared only after its corresponding cursor has been declared; otherwise, a compilation error will occur.

Advertisements
 
Leave a comment

Posted by on 05/09/2010 in ORACLE

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: