filmov
tv
| Oracle Boolean Data type | Function Restriction of Boolean Data type | Oracle Interview Question

Показать описание
In this video we will see the use of Boolean Data type and its use in Function and Restriction of Function during the use of Boolean Data type.
Scripts Are Given Below
---------------------------------------
Use Of Boolean Datatype in Oracle
-----------------------------------------------------------
- Boolean data type can store only two values such are "true"/"false"
- If we create a function whose return type is Boolean type, then we can't directly call it in "SELECT" statement.
- But we can call it in another Subprogram/Anonymous block
CREATE OR REPLACE FUNCTION is_emp_available (
p_empno IN NUMBER
) RETURN BOOLEAN AS
v_rec_cnt NUMBER DEFAULT 0;
BEGIN
SELECT COUNT(1)INTO v_rec_cnt FROM emp WHERE empno = p_empno;
IF ( v_rec_cnt = 0 ) THEN
RETURN false;
ELSE
RETURN true;
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN false;
END;
select is_emp_available(7369) from dual;
set serveroutput on;
declare
v_output boolean;
v_empno number;
begin
v_empno:=7369;
v_output:=is_emp_available(v_empno);
if(v_output=true) then
elsif(v_output=false) then
end if;
end;
/
Phone No- 8018319781
#Boolean_Datatype
#Oracle_Function_Restriction
#Oracle_SQL_PLSQL_Feature
Scripts Are Given Below
---------------------------------------
Use Of Boolean Datatype in Oracle
-----------------------------------------------------------
- Boolean data type can store only two values such are "true"/"false"
- If we create a function whose return type is Boolean type, then we can't directly call it in "SELECT" statement.
- But we can call it in another Subprogram/Anonymous block
CREATE OR REPLACE FUNCTION is_emp_available (
p_empno IN NUMBER
) RETURN BOOLEAN AS
v_rec_cnt NUMBER DEFAULT 0;
BEGIN
SELECT COUNT(1)INTO v_rec_cnt FROM emp WHERE empno = p_empno;
IF ( v_rec_cnt = 0 ) THEN
RETURN false;
ELSE
RETURN true;
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN false;
END;
select is_emp_available(7369) from dual;
set serveroutput on;
declare
v_output boolean;
v_empno number;
begin
v_empno:=7369;
v_output:=is_emp_available(v_empno);
if(v_output=true) then
elsif(v_output=false) then
end if;
end;
/
Phone No- 8018319781
#Boolean_Datatype
#Oracle_Function_Restriction
#Oracle_SQL_PLSQL_Feature
Комментарии