Close

Using Object Types: constructors

When an object type is instantiated (i.e. assigned a non-null value) it will execute initialization code. This initialization code is called a CONSTRUCTOR function. Every object type includes an implicit constructor which simply assigns values to the object attributes according to the values provided in the object assignment. For example: CREATE OR REPLACE TYPE simpleobject…

Nifty math trick with hierarchical query

Using the algorithm discovered by David Bailey, Peter Borwein, and Simon Plouffe, you can easily generate values of pi with a simple recursive query… SQL> SELECT d, to_char(bbp, rpad(‘0.’,55, ‘9’)) bbp,   2    TO_CHAR(   3       SUM(bbp) OVER (ORDER BY d),   4       ‘9.’ || RPAD(‘9’, d – 1, ‘9’)   5    ) pi  …