Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

II. Solutions > 20. Conversion, Numeric, and Miscellaneous Functions

Chapter 20. Conversion, Numeric, and Miscellaneous Functions

Beginner

Q:

20-1.

There are two related functions that accept a variable number of parameters: GREATEST and LEAST. They are used to return the greatest value in a list of values (GREATEST) or the least value in that list (LEAST).

Q:

20-2.

The snippet calls for you to use the LENGTH function to compute the length of the passed string. The wrinkle, though, is that the LENGTH function returns NULL, not zero, for a NULL string. Hence, you must wrap the call inside the NVL conversion function:

/* Print each character in a string */
CREATE OR REPLACE PROCEDURE nvl_test
   (i_val IN VARCHAR2 DEFAULT NULL)
IS
   str_len NUMBER := NVL (LENGTH (i_val), 0);
BEGIN
   FOR i IN 1 .. str_len
   LOOP
      DBMS_OUTPUT.put_line (UPPER (SUBSTR (i_val, i, 1)));
   END LOOP;
END;

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial