What is Boolean datatype in PLSQL Block.
A boolean datatype enables you to
declare
v_sal number;
v_flag boolean;
begin
select salary into v_sal from employees
where employee_id=&empno;
if v_sal >=10000 then
v_flag :=true;
else
v_flag :=false;
end if;
if v_flag = true then
dbms_output.put_line('High Grade');
else
dbms_output.put_line('Low Grade');
end if;
end;
/
You can also create table using boolean datatype.
Use an integer and just don't bother assigning anything
other than 0 or 1 to it.
Use a char field with 'Y' or 'N' these are the only two values.
Use an enum with the CHECK constraint.
create table student (rollno number primary key,
remarks char check (remarks in (0,1)))
A boolean datatype enables you to
declare
v_sal number;
v_flag boolean;
begin
select salary into v_sal from employees
where employee_id=&empno;
if v_sal >=10000 then
v_flag :=true;
else
v_flag :=false;
end if;
if v_flag = true then
dbms_output.put_line('High Grade');
else
dbms_output.put_line('Low Grade');
end if;
end;
/
You can also create table using boolean datatype.
Use an integer and just don't bother assigning anything
other than 0 or 1 to it.
Use a char field with 'Y' or 'N' these are the only two values.
Use an enum with the CHECK constraint.
create table student (rollno number primary key,
remarks char check (remarks in (0,1)))
0 comments:
Post a Comment