Skip to Content
Oracle PL/SQL Programming: A Developer's Workbook
book

Oracle PL/SQL Programming: A Developer's Workbook

by Steven Feuerstein, Andrew Odewahn
May 2000
Intermediate to advanced
594 pages
11h 32m
English
O'Reilly Media, Inc.
Content preview from Oracle PL/SQL Programming: A Developer's Workbook

Expert

18-41.

Write a function that left-pads the integer component and right-pads the decimal component of a string containing a number in a balanced way to return a string of a specified length and the decimal point (if it is present) located at the center position. For example, the string “23091958.47” with a specified length of 30 is changed to:

-- ruler 123456789012345678901234567890
         00000023091958.470000000000000

Here is the skeleton specification of the function:

CREATE OR REPLACE FUNCTION center_number ( p_num_to_center VARCHAR2,
                                           p_total_length  INT := 30 )
                           RETURN VARCHAR2 IS

  v_ret_val VARCHAR2(2000); -- return value

BEGIN

  RETURN(v_ret_val);

END;

18-42.

Write a function called betwnstr that returns the portion of a string that lies between specified start and end locations in the string, where (1) both start and end locations can be negative and (2) end can be less than start.

18-43.

Write a function called betwnstr that returns the portion of a string that lies between specified start and end substrings, as in:

FUNCTION betwnstr (
   str IN VARCHAR2, start_str IN VARCHAR2, end_str IN VARCHAR2 := NULL)
   RETURN VARCHAR2;

If end_str is NULL, return everything starting from the start_str’s location.

18-44.

Write a function to trim patterns, not individual characters, from the beginning of a string.

18-45.

Write a function that returns the location of the specified letter in a string that is closest to another specified letter, as in:

FUNCTION closest_loc (str IN VARCHAR2, findit IN VARCHAR, closeto ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Oracle Database 11g PL/SQL Programming Workbook

Oracle Database 11g PL/SQL Programming Workbook

Michael McLaughlin, John Harper

Publisher Resources

ISBN: 9781449324070Supplemental ContentErrata Page