Returning boolean from oracle function or procedure with out parameter

1.9k views Asked by At

I need to develop a web application with php.For login process , .Normally I would use select statement with id and password , if row returns then it is successful login.But I want to use stored procedure and don't want to get any row from database but simple boolean value.The signature of PL/SQL process is below.

procedure successful_login(cit_id in citizens.citizen_id%type,
                           pass in varchar2,v_login_successful out boolean)

I won't bloat page with code but procedure changes v_login_successful to true or false depending on successful login, in PL/SQL.But I want to call this procedure from PHP.If I bind a php variable to v_login_successful parameter and execute procedure from PHP, will PL/SQL engine return changed version of v_login_successful variable back to PHP?

1

There are 1 answers

0
Noel On

PL/SQL has Boolean datatype, but SQL doesn't have. Which means, you can

  1. use it in functions, procedures, anonymous blocks.
  2. use it as parameters in procedures and functions, only if they are used in PL/SQL context.

When you are calling the procedure from php, it will be a sql statement. You will get, expression is of wrong type exception.

Instead, you can use CHAR(1) (Y or N) or NUMBER(1) (0 or 1) datatype for out parameter.