Wednesday, April 22, 2009

Enforcing Standards With SubType

Create a new type by adding restrictions to an existing type with 'SubType.'
Create Or Replace Package p_Std
is
SubType City is VARCHAR2(25) ;
SubType State is CHAR(2) not null ;
end;
/
These can now be referenced:
Declare
v_City p_Std.City := 'Pittsburgh';
v_St p_Std.State := 'PA' ;
Begin
Dbms_Output.Put_Line (v_City ||', '||v_St);
End;
/
Pittsburgh, PA

PL/SQL procedure successfully completed.

No comments:

Post a Comment