Sunday, 2 August 2015

Create a data type that will only hold 0s and 1 s

Create a data type that will only hold 0 s and 1 s 





DECLARE
SUBTYPE flagtype IS PLS_INTEGER RANGE 0..1;
x flagtype;
BEGIN
BEGIN
x := 0;
dbms_output.put_line('Success: ' || TO_CHAR(x));
EXCEPTION
WHEN others THEN
dbms_output.put_line('Can not assign 0 to flagtype');
END;
BEGIN
x := 1;
dbms_output.put_line('Success: ' || TO_CHAR(x));
EXCEPTION
WHEN others THEN
dbms_output.put_line('Can not assign 1 to flagtype');
END;
....
END;
/

No comments:

Post a Comment