There are some pl/sql functions that you rarely use and we always forget the syntax.And here’s another example — the power function. You know, that’s the n to the power of x (n^x). Again, I feel a bit ashamed for forgetting this one. Here’s the syntax.


power(m,n);

whereby
m is the base.
n is the exponent.

Example

power(36,5);

will return 1679616

Take note that this function returns NUMBER as the data type. That means the maximum value can only be 1.0 x 10^126. Later versions (10g onwards) can use binary_double as the base which makes the function output binary_double. I don’t know where you would need that large number, though. Also, if m is negative, then n must be an integer.

In case you are asking where I need it, there’s this code conversion whereby I needed to use the power function to get the value of a particular character. The exponent(n) is not fixed so I needed this function. To be specific, the function involves the pl/sql version of RowIdToRowIdNum of Siebel. I’ll post the code later.

References:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1594387900346571874

Comments are closed.

Post Navigation