Databases Reference
In-Depth Information
How it works...
In step 2, we created a function
CONDITIONAL_COLUMN_LEN
, that calculates the maximum
length of data contained in the
COLUMN_NAME
field of
TABLE_NAME
, when the
COND_FIELD
is equal to
COND_VALUE
.
In step 3, the function is tested by calculating the maximum length of the data contained in
the
CUST_FIRST_NAME
field of the
CUSTOMERS
table for the records that have a
CUST_ID
between 1 and 10000.
In the following screenshot, you can see the execution output and the execution time:
In step 4, we have created the function
CONDITIONAL_COLUMN_LEN_BIND
, which is
equivalent to the one in step 3—except for the use of binding variables. In step 5, we have
executed this function using the same benchmark of step 3, obtaining the following output:
Hence, there is a huge performance improvement in our function when we use bind variables.