1

As detailed in this question, it's not possible to create OUT parameters with size restrictions in Oracle 10g. Has this situation improved with 11g?

Here's my real-world problem with this:

Oracle PL/SQL versions of INET6_ATON and NTOA functions?

You're welcome :) However, the one thing I do not like about these functions is the lack of a RETURN CHAR(32) forces any function-based index (FBI) to use the maximum VARCHAR2 size of 4000 for the entire index (which would usually error out because of index field size restrictions), unless you encapsulate the entire thing in a SUBSTR, forcing a fixed size. This is ugly to use in a typical SQL statement as you now have to make sure everybody is not only using the functions, but also using the SUBSTR encapsulation, so that the index is used properly.

Would virtual columns solve this problem? As in, you define virtual columns for each IP, like srcip_iptohex, srcip_nettohex_start, srcip_nettohex_end, and then put the CHAR(32) restriction on the virtual columns. Or do virtual columns even support PL/SQL calls? Since the virtual columns don't actually get stored, you would still need to index the columns to make sure they are useful.

Community
  • 1
  • 1
SineSwiper
  • 2,046
  • 2
  • 18
  • 22
  • [The docs look promising](http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_7002.htm#BABIJABG). So, it does look like you can use PL/SQL statements within virtual columns. – SineSwiper May 31 '12 at 23:36

1 Answers1

1

You can't alter the type of a virtual column, this results in ORA-54027 cannot modify data-type of virtual column.

You can however define a virtual column with a SUBSTR (which will give the column the appropriate size), then index this virtual column. All queries against this column will be able to use the index without the need for additional "ugly" SUBSTR.

Vincent Malgrat
  • 66,725
  • 9
  • 119
  • 171