Login   Search
Skip Navigation Links
Home
Application Security Tips
Oracle , PL/SQL
IT Product Reviews
Project Management
Forum
Contact Us
Links & References
Avoid SQL Injection attack
Threats and Countermeasures: S.T.R.I.D.E
Input Validation
Session Management
Authentication Mechanism
Cross Site Scripting Vulnerabilities
Configuration Management
Scroll up
Scroll down
Oracle 9i - Programming basics PL/SQL
PL/SQL - Conditional Statements – IF
PL/SQL -Nested Block
LOOPS in PL/SQL
PL/SQL Records
Cursors in PL/SQL
PL/SQL Tables
PL/SQL Exceptions
PL/SQL Procedures
PL/SQL Functions
Oracle supplied packages
Packages
PL/SQL Ref Cursors
Types in Oracle PL/SQL
Varrays
Nested Table
Bfile and LOBs
Bulk Binding
Know Depandencies
PL/SQL Wrapper
Triggers
Scroll up
Scroll down
DBMS_SQL package
DBMS_DDL Package
DBMS_JOB Package
UTL_FILE Package
DBMS_METADATA Package
DBMS_PIPE Package
DBMS_SESSION Package
Scroll up
Scroll down

 

Blog

  • Following coding best practices and style guides
  • Imperativeness of agile methodology in software development
  • Get list of installed softwares on machines in your network
  • VMWare - Error - the vmware authorization service is not running
  • Add chart / graphs in ASP.net application / website

Blog

  • Review: uCertify.com: PrepKit for: 70-529 (C#)
  • Bird eye Review: uCertify.com: PrepKit for: 70-529 (C#)
Skip Navigation Links>Oracle , PL/SQL>PL/SQL Records

PL/SQL Records

Objects of type RECORD are called PL/SQL records
PL/SQL records have uniquely named fields, which can belong to different datatypes
Define a RECORD type

TYPE IS RECORD

(fieldname1
 :
 fieldnameN ;

(%TYPE and %ROWTYPE can be used to specify ]


Example 1 of Record Type –

Declare

TYPE empdetails IS RECORD
(eno Emp.Empno%type,
name Emp.Ename%type,
s Emp.Sal%type);

VE empdetails;

Begin
 Select empno,ename,sal Into  VE
 from Emp
 where ename = 'SMITH';
 dbms_output.put_line(VE.eno || ' - ' || VE.name || '-' ||VE.s);
End;


Example 2 of Record Type –

Declare
 TYPE si IS RECORD
 (p number,
 n number,
 r number := 4.5);

/* r variable of si type has been given value. */
VSI  si;
x number;
Begin
VSI.p  :=  5000;
VSI.n  :=  6;
x := (VSI.p * VSI.n * VSI.r) / 100;
dbms_output.put_line(x);
End;

Using a record type in another record type.

Declare
type Address_details is record
 (sector char(3),
 colony varchar2(50),
 bldg_name varchar2(25),
 pincode number(7));
 type personal_details is record
 (name varchar2(60),
 Addr  Address_Details,
 age number);
 
 V personal_details;
 Begin
 V.name := 'John';
 V.Addr.sector := 'S1';
 V.Addr.colony := 'Model';
 V.Addr.bldg_name := 'Hill View';
 V.Addr.pincode := 6775;
 dbms_output.put_line('The building name is ' || V.Addr.bldg_name);
 dbms_output.put_line('The pincode is  ' ||V.Addr.pincode);
End;

  -------------------------------------

%Rowtype with Record

declare

type t1 is record
 (ed emp%rowtype,
 dd dept%rowtype);
 VT1 t1;
Begin
 select * into VT1.ed
 from emp
 where ename = 'KING';

 select * into VT1.dd
 from dept
 where dname = 'ACCOUNTING';
 dbms_output.put_line(VT1.ed.ename);
 dbms_output.put_line(VT1.dd.dname);
end;


SubjectLast EntryRepliesHits
Discussion about this article
admin
8/24/2009 3:26 PM
admin
0253


Designed & Developed by Rahul Bagal