July 16, 2007
Question 3
Which of the following is a valid wildcard character in a LIKE clause of a SELECT statement?
A. %
B. *
C. ?
D. \
The answer and another sample question follow.
Answer 3
The correct answer is A. The pattern of characters specified with the LIKE clause of a SELECT statement can consist of regular alphanumeric characters and/or special metacharacters that are interpreted as follows:
• The underscore character (_) is treated as a wild card character that stands for any single alphanumeric character.
• The percent character (%) is treated as a wild card character that stands for any sequence of alphanumeric characters.
Question 4
Given the following table:
TEMP_DATA
TEMP DATE
---- ----------
45 12/25/2006
51 12/26/2006
67 12/27/2006
72 12/28/2006
34 12/29/2006
42 12/30/2006
And the following SQL statement:
CREATE FUNCTION degf_to_c (temp INTEGER)
RETURNS INTEGER
LANGUAGE SQL
CONTAINS SQL
NO EXTERNAL ACTION
DETERMINISTIC
BEGIN ATOMIC
DECLARE newtemp INTEGER;
SET newtemp = temp - 32;
SET newtemp = newtemp * 5;
RETURN newtemp / 9;
END
Which two of the following SQL statements illustrate the proper way to invoke the scalar function DEGF_TO_C?
A. VALUES degf_to_c(32)
B. SELECT date, degf_to_c(temp) AS temp_c FROM temp_data
C. CALL degf_to_c(32)
D. SELECT * FROM TABLE( degf_to_c(temp)) AS temp_c
E. VALUES degf_to_c(32) AS temp_c
Answer 4
The correct answers are A and B. How a user-defined function is invoked depends a lot on what it has been designed to do; scalar user-defined functions can be invoked as an expres-sion in the select list of a query while table and row functions must be referenced by the FROM clause. In because the user-defined function used in this example is a scalar function that only returns a single value, answer B is the correct way to call it. A scalar function can also be invoked by executing a VALUES statement that looks something like the one shown in answer A.
« DB2 LUW Performance: More Key Costs | Main | Four names you'd never expect to see on DB2mag.com: Vanity Fair, Bono, Africa, and Bill Clinton »
This is a public forum. CMP Media and its affiliates are not responsible for and do not control what is posted herein. CMP Media makes no warranties or guarantees concerning any advice dispensed by its staff members or readers.
Community standards in this comment area do not permit hate language, excessive profanity, or other patently offensive language. Please be aware that all information posted to this comment area becomes the property of CMP Media LLC and may be edited and republished in print or electronic format as outlined in CMP Media's Terms of Service.
Important Note: This comment area is NOT intended for commercial messages or solicitations of business.
