A routine must accept a start date and an end date, return a multi-row sales summary for that range, and insert a row into a report_log table every time it runs. Which database object should implement this routine?
Select an answer to reveal the explanation.
Short Explanation
When the job description includes "and also write something," you're in stored procedure territory. Views just look, scalar functions hand back one value, but a procedure can take your dates, return a result set and log the run. Watch for that side-effect clue, because it's what decides the answer.
Full Explanation
A stored procedure is a named routine that accepts input parameters, can run multiple statements including INSERT, UPDATE and DELETE, and can return one or more result sets. That combination covers all three requirements: the date range arrives as parameters, the summary query returns the rows, and an INSERT into report_log records each execution within the same routine. A view is a saved SELECT; in standard usage it takes no parameters and performs no writes, so it can neither accept the date range directly nor log its own use. A scalar function returns exactly one value per call, so it cannot return a multi-row summary, and functions are conventionally reserved for computing values without side effects. A computed column derives a value for each row from other columns in the same row; it cannot aggregate across a date range, take parameters or write to another table. Exam caveat: some engines offer table-valued functions that return rows, and some allow functions with side effects, but the objective's distinction is that procedures are the object meant to perform actions that modify data. Operational check: create the procedure in a test environment, execute it with a sample date range, confirm the summary rows are correct, and verify that report_log gained exactly one row with the parameters used.