View the Exhibit and examine the structure of the ORDERS and ORDER_ITEMS tables.
In the ORDERS table, ORDER_ID is the PRIMARY KEY and ORDER_DATE has the DEFAULT value as SYSDATE.
Evaluate the following statement:
UPDATE orders
SET order_date=DEFAULT
WHERE order_id IN (SELECT order_id FROM order_items WHERE qty IS NULL);
What would be the outcome of the above statement?
A.
The UPDATE statement would not work because the main query and the subquery use different tables.
B.
The UPDATE statement would not work because the DEFAULT value can be used only in INSERT statements.
C.
The UPDATE statement would change all ORDER_DATE values to SYSDATE provided the current ORDER_DATE is NOT NULL and QTY is NULL.
D.
The UPDATE statement would change all the ORDER_DATE values to SYSDATE irrespective of what the current ORDER_DATE value is for all orders where QTY is NULL.
Hi, the answer says it is option D.
I tried the query on SQL developer. But it did not update all the ORDER_DATE value to SYSDATE.
It did not change all the rows values like D says.
I think D is incorrect. Someone pls help explain why D is correct.
insert into orders values (19, ”, ‘new’, 8, ”, 1000, ”,”);
insert into orders values (110, ‘Jan-13-2018’, ‘fx’, 8, ”, 1000, ”,”);
select * from orders;
select * from order_items;
insert into order_items values (113, 100, 100, 100, 1);
UPDATE orders
SET order_date=sysdate
WHERE order_id IN (SELECT order_id FROM order_items WHERE quantity IS NULL);
So D is correct. The query will update the rows for the order where quantity IS NULL in the subquery. This is what answer D is stated.
yes, D is correct