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.

Declaring and Initializing Record Types


DECLARE

-- Declare a record type with 3 fields.

TYPE REC1_T IS RECORD(FIELD1 VARCHAR2(16),

FIELD2 NUMBER,

FIELD3 DATE);

-- For any fields declared NOT NULL, we must supply a default value.

TYPE REC2_T IS RECORD(ID INTEGER NOT NULL := -1,

NAME VARCHAR2(64) NOT NULL := '[anonymous]');

-- Declare record variables of the types declared

REC1 REC1_T;

REC2 REC2_T;

-- Declare a record variable that can hold a row from the EMPLOYEES table.

-- The fields of the record automatically match the names and

-- types of the columns.

-- Don't need a TYPE declaration in this case.

REC3 EMPLOYEES%ROWTYPE;

-- Or we can mix fields that are table columns with user-defined fields.

TYPE REC4_T IS RECORD(FIRST_NAME EMPLOYEES.FIRST_NAME%TYPE,

LAST_NAME EMPLOYEES.LAST_NAME%TYPE,

RATING NUMBER);

REC4 REC4_T;

BEGIN

-- Read and write fields using dot notation

REC1.FIELD1 := 'Yesterday';



REC1.FIELD2 := 65;



REC1.FIELD3 := TRUNC(SYSDATE - 1);



-- We didn't fill in the name field, so it takes the default value declared

DBMS_OUTPUT.PUT_LINE(REC2.NAME);

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