plsql - Check if a column has a certain entry in a PL/SQL function -
i've table 2 columns. second column foreign key column. want check if there record foreign key x
in column. i'm using (rather learning) pl/sql on oracle 11g.
edit: use sql
select
*
how use in pl/sql return boolean in function?
function my_func () return boolean l_contains_x number; l_contains_x_bool boolean := false; begin select 1 l_contains_x dual exists ( select 1 table col = x ); if l_contains_x = 1 l_contains_x_bool := true; end if; return l_contains_x_bool; end;
note key here keyword returns values variables. these positionally matched select 4 columns 4 variables (or * rowtype). expects 1 value why have moved check exists, outer select selects 1 value.
note sql has no concept of boolean type function usable in pl/sql context. if want true / false coming in sql context should use varchar2 'true' , 'false'.
Comments
Post a Comment