I am trying to perform the following query “Create a view which restricts staff user access to the order table to the working hours between 9:00 and 18:00. Grant appropriate
permissions to the staff users.”
However I am struggling, what I have used so far is the following:
CREATE VIEW STAFF_RESTRICTORDERVIEW AS
SELECT TO_CHAR (SYSDATE, 'DD-MM-YYYY HH24:MI:SS'), ORDERNUMBER, CUSTOMERNUMBER, DATEORDERPLACED, DELIVERYINSTRUCTION, SCHEDULEID,
FROM ORDERS
WHERE STAFF_RESTRICTORDERVIEW (SYSDATE, 'DD-MM-YYYY HH24:MI:SS') NOT BETWEEN
(SYSDATE, 'DD-MM-YYYY 09:00:00') AND (SYSDATE, 'DD-MM-YYYY 18:00:00')
If that code above worked, then I would have been able to add the following:
GRANT SELECT on STAFF_RESTRICTORDERVIEW TO 'STAFF_USER'
Any help would be appreciated, thanks in advance :).
Try this:
I believe that this would return an empty recordset if you run it between 9:00 and 18:00. If you want the reverse, to only get records between those hours, then remove the NOT from the final line.