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: Daniel A. Morgan <dmorgan_at_exesolutions.com>
Date: Tue, 17 Apr 2001 22:21:36 -0700
Message-ID: <3ADD2460.54953F92@exesolutions.com>

Try decode.

SELECT DECODE(booleanvar, True, 1, 0)
FROM ....; Daniel A. Morgan

Ian Ledzion wrote:

> 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.
Received on Wed Apr 18 2001 - 00:21:36 CDT

Original text of this message

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