Composite Data types

Composite Data types - Composite Data types collections....

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Composite Data types collections. .
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Scalar data type revisited… Bind variable(reading columns) Collection types Index-by-table(plsql table) Nested table varray
Background image of page 2
PL/SQL variable revisited BINARY_INTEGER : This type manipulates signed integers in the range of -2,147,483,647 to 2,147,483,647. NATURAL : A subset of BINARY_INTEGER, this data type is the set of integers from 0 to 2,147,483,647. POSITIVE: Another subset of BINARY_INTEGER, the POSITIVE data type is the set of integers from 1 to 2,147,483,647.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
For nested tables, the legal subscript range is 1 . . 2147483647. But, for index-by tables, the range is -2147483647 . . 2147483647 . So, unlike nested tables, index-by tables can have negative subscripts. To extend a nested table, you must use the built-in procedure EXTEND. But, to extend an index-by table, you just specify larger subscripts.
Background image of page 4
Bind variable variable no number; set serveroutput on DECLARE emp_det emp%ROWTYPE; BEGIN :no:=7369; SELECT * INTO emp_det FROM emp WHERE empno = :no; DBMS_OUTPUT.PUT_LINE(emp_det.ename); DBMS_OUTPUT.PUT_LINE(emp_det.job); DBMS_OUTPUT.PUT_LINE(emp_det.deptno); END;
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
There are three types of collections: index-by tables (formerly known as PL/ SQL tables), nested tables, and VARRAYs.
Background image of page 6
PL/SQL Records PL/SQL records provides a way to deal with separate but related variables as a unit PL/SQL record is a variable that may contain a collection of separate values, each individually addressable The record type has to be defined before its record can be declared
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
declare /*declare a record type to hold common student information*/ TYPE stud_rec is RECORD( stud_id number(5), v_firstname varchar2(20), v_lastname varchar2(20), address varchar2(20)); /* declare a variable of this type*/ studerec stud_rec; begin studerec.stud_id:=101; studerec.v_firstname:='vaishali'; studerec.v_lastname:='kadam'; studerec.address:='pune'; end; /
Background image of page 8
set serveroutput on declare TYPE emp_record_type IS RECORD (employee_id emp.empno%type, name emp.ename%TYPE, job_id emp.job%TYPE); emp_record emp_record_type; begin select empno,ename,job into emp_record from emp where empno=7369; dbms_output.put_line(emp_record.name); dbms_output.put_line(emp_record.job_id); end;
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Collections Store multiple values of the same data type Similar to arrays in other languages
Background image of page 10
Oracle uses collections in PL/SQL the same way other languages use arrays. Oracle provides three basic collections, each with an assortment of methods. Index-By Tables
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/15/2011 for the course ECO 2023 taught by Professor Mr.raza during the Summer '10 term at FAU.

Page1 / 45

Composite Data types - Composite Data types collections....

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online