Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Convert Boolean
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
![]() |
![]() |