4 Replies Latest reply: Apr 16, 2007 2:15 PM by 551707 RSS

    BITOR, BITXOR, BITNOT - where to place them?

    551707
      Currently, Oracle has only one bitwise operator - BITAND. All other bitwise operators, such as
      BITOR, BITXOR, BITNAND, BITNOR, BITXNOR and BITNOT, must be derived from BITAND
      and/or other (from it) consecutively derived operators.

      I've created three functions for three bitwise operators : BITOR, BITXOR and BITNOT:
      -- BITOR
      CREATE FUNCTION "SYS"."BITOR" (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
      BEGIN
        RETURN (x + y - BITAND(x, y));
      END;
      /
      GRANT EXECUTE ON SYS.BITOR TO PUBLIC;
      CREATE PUBLIC SYNONYM "BITOR" FOR "SYS"."BITOR";


      -- BITXOR
      CREATE FUNCTION "SYS"."BITXOR" (x IN NUMBER, y IN NUMBER) RETURN NUMBER AS
      BEGIN
        RETURN (BITOR(x, y) - BITAND(x, y));
      END;
      /
      GRANT EXECUTE ON SYS.BITXOR TO PUBLIC;
      CREATE PUBLIC SYNONYM "BITXOR" FOR "SYS"."BITXOR";


      -- BITNOT
      CREATE FUNCTION "SYS"."BITNOT" (x IN NUMBER) RETURN NUMBER AS
      BEGIN
        RETURN (-1 - x);
      END;
      /
      GRANT EXECUTE ON SYS.BITNOT TO PUBLIC;
      CREATE PUBLIC SYNONYM "BITNOT" FOR "SYS"."BITNOT";
      The functions are created in SYS schema and works well. My question is:

      whenever a system-wide accessible function (a function available to all users just like
      any other Oracle's built-in function) is to be created, what is appropriate place to
      create it? Is it SYS, SYSTEM or SYSAUX schema?

      Also, if anyone has a better coding solution for these functions (operators), please let
      me know.

      Thanks a lot.

      Albert
        • 1. Re: BITOR, BITXOR, BITNOT - where to place them?
          ushitaki
          whenever a system-wide accessible function (a function available to all users just like
          any other Oracle's built-in function) is to be created, what is appropriate place to
          create it? Is it SYS, SYSTEM or SYSAUX schema?
          I think those had better be created in general schema (not SYS,SYSTEM nor SYSAUX)
          and use public synonym for refer.
          • 2. Re: BITOR, BITXOR, BITNOT - where to place them?
            551707
            I think those had better be created in general schema (not SYS,SYSTEM nor SYSAUX)
            and use public synonym for refer.
            Maybe. In fact I would like to know what is general Oracle's recommendation where to put such sort of UDFs. I failed to find guidelines for it in Oracle's official documentation.

            Thanks a lot.

            Albert
            • 3. Re: BITOR, BITXOR, BITNOT - where to place them?
              519688
              oracle's long standing recommendation is that you do not put anything in any of the supplied oracle accounts (sys, system, sysaux). putting something there could affect later patches or upgrades - perhaps oracle will choose to create it's own object which the same name as the one you made, and either the upgrade fails, or you lose your objects.
              • 4. Re: BITOR, BITXOR, BITNOT - where to place them?
                551707
                oracle's long standing recommendation is that you do
                not put anything in any of the supplied oracle
                accounts (sys, system, sysaux). putting something
                there could affect later patches or upgrades -
                perhaps oracle will choose to create it's own object
                which the same name as the one you made, and either
                the upgrade fails, or you lose your objects.
                Yes, that's it. Understood. Thanks.

                Albert