View the exhibit and examine the description for the SALES and CHANNELS tables.
You issued the following SQL statement to insert a row in the SALES table:
INSERT INTO sales VALUES
(23, 2300, SYSDATE, (SELECT channel_id
FROM channels
WHERE channel_desc=’Direct Sales’), 12, 1, 500);
Which statement is true regarding the execution of the above statement?
A.
The statement will execute and the new row will be inserted in the SALES table.
B.
The statement will fail because subquery cannot be used in the VALUES clause.
C.
The statement will fail because the VALUES clause is not required with subquery.
D.
The statement will fail because subquery in the VALUES clause is not enclosed with in single quotation
marks.
The question is not clear:
For me the answer is B
1. The number of the columns into the INSERT statement is greater than the number of column accepted from the table SALES;
2. You cannot use the subquery when you are using the “VALUES” statement
3. The subquery queries channel_desc, wich is not clear if return one or more values.
not clear indeed.
I would assumed the picture is wrong (missing a column) and go with A.
1. number of columns in the insert and the table is indeed different and would cause an error
2. subquery does work when using values (at least when I tested it in 12.1) … B,C false
3. if the sub query does indeed return more than 1 row it would cause an error
4. single quotes are not required
It will execute sucessfully only if the subquery returns only one row.
https://stackoverflow.com/questions/21220934/can-a-subquery-be-used-with-the-values-keyword
“You need to insert subqueries in parentheses. The opening paren for values doesn’t count. It is the start of a list, not a subquery. You can include subqueries in the VALUES clause when they return one row and one column.”
Answer B