Search This Blog

Monday, April 6, 2015

api to register table, columns easily with cursor using user tables.

0.

begin
ad_dd.register_table
(p_appl_short_name =>  'XXCUST',    --Application name in which you want to register
p_tab_name      =>'XX_FFRD_PER_INFO_HEADER', --Table Name
p_tab_type      =>'T',   -- T for Transaction data , S for seeded data
p_next_extent     =>  512,   -- default 512
p_pct_free        =>  10,   -- Default 10
p_pct_used        =>  70 --Default 70
);
end;


1.

DECLARE
CURSOR C1 IS
SELECT  * FROM  USER_TAB_COLUMNS
WHERE TABLE_NAME = 'XX_FFRD_PER_INFO_HEADER'
--AND COLUMN_NAME NOT IN ('PER_NAME','PER_EID')
;
begin
FOR I IN C1 LOOP
ad_dd.register_column
(p_appl_short_name =>   'XXCUST', --Application Name
p_tab_name      =>  'XX_FFRD_PER_INFO_HEADER', --Table Name
p_col_name     =>   I.COLUMN_NAME, --Column Name
p_col_seq      =>   I.COLUMN_ID, --Column Sequence
p_col_type     =>   I.DATA_TYPE, --Column Data type
p_col_width    =>   I.DATA_LENGTH, --Column Width
p_nullable        =>   'N', --Use'N' if mandatory column otherwise 'Y'
p_translate       =>   'N', --Use 'Y' if this has translatable values
p_precision       =>   null, --Decimal precision
p_scale           =>   NULL --Number of digits in number
);
END LOOP;
end;

Commit;

2.
Begin
ad_dd.register_primary_key
(p_appl_short_name =>   'XXCUST', --Application Name
p_key_name        =>   'XX_FFRD_PER_INFO_HEADER_PK', --Unique name for primary key
p_tab_name      =>   'XX_FFRD_PER_INFO_HEADER', --Table Name
p_description     =>   'EID PRIMARY KEY', --Description
p_key_type        =>   'S', --S for Surrogate, D for Developer
p_audit_flag      =>   'Y',
p_enabled_flag    =>   'Y');
end;
commit;

3.

USER.USER_ID

USER_RESP

Begin
ad_dd.register_primary_key_column
(p_appl_short_name =>  'XXCUST', --Application Name
p_key_name        =>  'XX_FFRD_PER_INFO_HEADER_PK', --Primary Key name given above
p_tab_name        =>  'XX_FFRD_PER_INFO_HEADER',--Table Name
p_col_name        =>  'PER_EID', --Primary Column name
p_col_sequence    =>  1); --Column seq
end;

No comments:

Post a Comment