Previous | Table of Contents | Next

Page 98

Q Sometimes you capitalize your date format strings. Why?
A When converting a date to a character string for display purposes, capitalizing parts of the format string controls whether or not that part of the date is capitalized. Suppose that it is currently the month of January. The expression TO_CHAR(SYSDATE,'mon') would result in a value of `jan', the expression TO_CHAR(SYSDATE,'Mon') would result in a value of `Jan', and the expression TO_CHAR(SYSDATE,'MON') would result in a value of `JAN'.

Workshop

Use the following workshop to test your comprehension of this chapter and put what you've learned into practice. You'll find the answers to the quiz and exercise in Appendix A, "Answers."

Quiz

  1. What is the difference between a unary operator and a binary operator?
  2. What are the results of each of the following expressions?
    a. (5-4)-(3-1)
    b. 4*2**3-2
    c. 4*2**(3-2)
    d. 4=4 AND 5=6 OR 3=3
  3. Using the NOT operator, write equivalent expressions for each of the following:
    a. A <> B
    b. A < B
    c. (A <= B) AND (B <= C)
  4. Match the patterns and strings shown following. Hint: Not every string or pattern has a match, and one pattern matches more than one string.
    `123-45-6789''___-__-____'
    
    `Boom''John%'
    
    `Johnson''_oo_'
    
    `517-555-1212'
    
    `Broom'
    
    `Jonson'
    
    `Johnston'
    
  5. When does PL/SQL not pad strings with spaces, in order to make them of equal length, when doing comparisons?

Page 99

Exercise

Write a function to compute wages based on an hourly rate and the number of hours worked. Have it use a minimum wage of $5 per hour if the rate is unknown. Have it also use the minimum wage if the rate is too low.

Page 100

Previous | Table of Contents | Next

Используются технологии uCoz