View the Exhibit and examine the structure of the PROMOTIONS table.
Which two SQL statements would execute successfully? (Choose two.)
A.
UPDATE promotions
SET promo_cost = promo_cost+ 100
WHERE TO_CHAR(promo_end_date, ‘yyyy’) > ‘2000’;
B.
SELECT promo_begin_date
FROM promotions
WHERE TO_CHAR(promo_begin_date,’mon dd yy’)=’jul 01 98′;
C.
UPDATE promotions
SET promo_cost = promo_cost+ 100
WHERE promo_end_date > TO_DATE(SUBSTR(’01-JAN-2000′,8));
D.
SELECT TO_CHAR(promo_begin_date,’dd/month’)
FROM promotions
WHERE promo_begin_date IN (TO_DATE(‘JUN 01 98’), TO_DATE(‘JUL 01 98’));
Why D is incorrect?
because the to_date functions in the where clause needed a mask to work
like to_date(‘JUN 01 98′,’MON DD YY’)
Just a note: the TO_CHAR() format mask argument is optional, but in this particular case, because ‘JUN 01 98’ is not in default format, a format mask is required or TO_CHAR will throw an error.
http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions183.htm
because there is no format model on to date function
A. and B. surely work
D. can work if the NLS Format is set to ‘MON DD YYYY’
In my case:
select promo_begin_date
FROM promotions
WHERE promo_begin_date in (TO_DATE(’10-AGO-2000′), TO_DATE(’23-AGO-2000′)) ;
WORKS
C would work if it was written like this: TO_DATE(SUBSTR(’01-JAN-2000′,8), ‘YYYY’).