record is complex data type , means a combination of all the normal primitive data types, record is type of row in a table , which contains a columns of each different type
Syntax for declaring record is
TYPE record_type IS RECORD
(first_name first_name,.......);
if for example u want to assign a column data type of a table then do like below
first_name table_name.column_name%type ;
NOTE: You can use also %type to declare variables and constants.
now lets declare the record as below
record_name record_type;
now lets create simple record type
if we want to take all the fields from a table then
Syntax for declaring record is
TYPE record_type IS RECORD
(first_name first_name,.......);
if for example u want to assign a column data type of a table then do like below
first_name table_name.column_name%type ;
NOTE: You can use also %type to declare variables and constants.
now lets declare the record as below
record_name record_type;
now lets create simple record type
DECLARE TYPE employee_type IS RECORD (employee_id number(5), employee_first_name varchar2(25), employee_last_name employee.last_name%type, employee_dept employee.dept%type); employee_salary employee.salary%type; employee_rec employee_type; |
if we want to take all the fields from a table then
DECLARE
employee_rec employee%ROWTYPE;
how to assign values to the fields in the record ?
record_name.col_name : =value;
if it is rowtype then
record_name.column_name := value;
how to assign values using select statement ?
select col1,col2
into
record_name.filed_name1,record_name.filed_name2
from table_name
[where]
assigning the values ok then how to get the value from record ?
like below :)
var_name := record_name.col_name;
No comments:
Post a Comment