Composite Type:-
=============
Composite type allows you to group the variables. Composite type are two type.
1. Record type. (one row with n columns).
2. Collections or pl/sql tables.
/************************** Record Type ******************************/
It allows you to group the variables, all the variables may be same datatype or differenet datatype.
A)
create or replace procedure xx_po_record_row_type_prod(P_HEADER_ID number)
is
--************** defining table record type *****************---
po_headers_rec PO_HEADERS_ALL%rowtype;
--po_headers_rec is record type. PO_HEADERS_ALL%rowtype will create the variables with the same name of the columns in the
PO_HEADERS_ALL table and it will group all the variables into po_headers_rec
begin
SELECT * INTO po_headers_rec from PO_HEADERS_ALL where PO_HEADER_ID=P_PO_HEADER_ID; --only one row allowed.
-- here *(star) must be used as po_headers_rec is type of table_name%rowtype
dbms_output.put_line('PO Number :- ' || po_header_rec.segment1);
end xx_po_record_row_type_prod;
/
B)
create or replace procedure xx_vendor_record_type_prod(P_VENDOR_ID number)
is
--************** defining custom record type *****************---
type vendor_type is recode(vendor_id number,
segment1 varchar2(40), --vendor number
vendor_name varchar2(240),
vendor_type_lookup_code varchar2(240)
);
vendor_rec vendor_type;
--- vendor_type is user define type with custom columns.
begin
SELECT vendor_id,vendor_num,vendor_name,vendor_type_lookup_code INTO vendor_rec FROM ap_suppliers WHERE
venoder_id=p_vendor_id; --only one row allowed.
dbms_output.put_line('Supplier Num:- ' || vendor_rec.segment1);
dbms_output.put_line('Supplier Name:- ' || vendor_rec.vendor_name);
end xx_vendor_record_type_prod;
/
=============
Composite type allows you to group the variables. Composite type are two type.
1. Record type. (one row with n columns).
2. Collections or pl/sql tables.
/************************** Record Type ******************************/
It allows you to group the variables, all the variables may be same datatype or differenet datatype.
A)
create or replace procedure xx_po_record_row_type_prod(P_HEADER_ID number)
is
--************** defining table record type *****************---
po_headers_rec PO_HEADERS_ALL%rowtype;
--po_headers_rec is record type. PO_HEADERS_ALL%rowtype will create the variables with the same name of the columns in the
PO_HEADERS_ALL table and it will group all the variables into po_headers_rec
begin
SELECT * INTO po_headers_rec from PO_HEADERS_ALL where PO_HEADER_ID=P_PO_HEADER_ID; --only one row allowed.
-- here *(star) must be used as po_headers_rec is type of table_name%rowtype
dbms_output.put_line('PO Number :- ' || po_header_rec.segment1);
end xx_po_record_row_type_prod;
/
B)
create or replace procedure xx_vendor_record_type_prod(P_VENDOR_ID number)
is
--************** defining custom record type *****************---
type vendor_type is recode(vendor_id number,
segment1 varchar2(40), --vendor number
vendor_name varchar2(240),
vendor_type_lookup_code varchar2(240)
);
vendor_rec vendor_type;
--- vendor_type is user define type with custom columns.
begin
SELECT vendor_id,vendor_num,vendor_name,vendor_type_lookup_code INTO vendor_rec FROM ap_suppliers WHERE
venoder_id=p_vendor_id; --only one row allowed.
dbms_output.put_line('Supplier Num:- ' || vendor_rec.segment1);
dbms_output.put_line('Supplier Name:- ' || vendor_rec.vendor_name);
end xx_vendor_record_type_prod;
/
No comments:
Post a Comment