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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Convert Boolean

Re: Convert Boolean

From: fumi <fumi_at_tpts5.seed.net.tw>
Date: Thu, 19 Apr 2001 17:16:55 +0800
Message-ID: <9bmkou$6cm$3@news.seed.net.tw>

"Daniel A. Morgan" <dmorgan_at_exesolutions.com> ????? news:3ADD2460.54953F92_at_exesolutions.com...
> Try decode.
>
> SELECT DECODE(booleanvar, True, 1, 0)
> FROM ....;
>
> Daniel A. Morgan

Obviously, it does NOT work.
The datatype BOOLEAN is not suppored in SQL.

>
> > Is there a package function or other method to convert BOOLEAN values to
> > something else, e.g. numeric within a query?
> >
> > I've checked the built-in packages with no luck (though maybe I missed
> > something), then tried my own function, which is below:
> >
> > CREATE OR REPLACE
> > FUNCTION test_conv (p_boolean IN BOOLEAN)
> > RETURN NUMBER
> > IS
> > v_value NUMBER DEFAULT 0;
> > BEGIN
> > IF p_boolean
> > THEN
> > v_value := 1;
> > END IF;
> >
> > RETURN v_value;
> > END;
> > /
> >
> > This works fine in an anonymous SQL block, but no luck in a query. The
> > error message I get is:
> >
> > ORA-06552: PL/SQL: Statement ignored ORA-06553: PLS-382: expression is of
> > wrong type
> >
> > Any thoughts would be much appreciated.

If your functions use paremeters or return value of boolean datatype, they can be used only in PL/SQL, not in SQL. Received on Thu Apr 19 2001 - 04:16:55 CDT

Original text of this message

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