Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Functions and Boolean datatype

Re: Functions and Boolean datatype

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Mon, 07 Sep 1998 17:23:24 GMT
Message-ID: <35f91615.5752932@192.86.155.100>


A copy of this was sent to "Gocha Mchedlishvili" <gocham_at_mci2000.com> (if that email address didn't require changing) On Sun, 6 Sep 1998 22:06:57 -0400, you wrote:

>Hi
>Is there any way I can pass boolean expressions into custom function and how
>to get this expression in function:
>
>select cutomFunction(1=1) from dual
>
>Thanks
>
>Gocha
>
>

Yes and no. In pl/sql -- YES, in SQL (which does not understand the concept of the datatype BOOLEAN) no.

for example (ite stands for If Then Else):

SQL> create or replace function ite( x in boolean, yes in varchar2, no in varchar2 )
  2 return varchar2
  3 is
  4 begin

  5     if ( x ) then return yes;
  6     else return no;
  7     end if;

  8 end;
  9 /

Function created.

SQL> exec dbms_output.put_line( ite( 1=1, 'One equals One', 'Not Equal' ) ); One equals One

PL/SQL procedure successfully completed.

so, it works fine in PL/SQL but in SQL you'll get a parse error such as:

SQL> select ite( 1=1, 'One equals One', 'Not Equal' ) from dual; select ite( 1=1, 'One equals One', 'Not Equal' ) from dual

             *
ERROR at line 1:
ORA-00907: missing right parenthesis  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Herndon VA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Mon Sep 07 1998 - 12:23:24 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US