I'm trying to create a procedure to limit the dataset I have before doing an actual query from a web base application. (PHP).
I'm trying to write a stored procedure to limit the dataset by a timestamp.
For instance I have thousands of tuples in the database, each of which has a field to represent the time (Date datatype).
In a query I would simply do a:
SELECT * FROM mytable WHERE timestamp BETWEEN (sysdate - 1) AND sysdate
This works fine and simple in a query, however when I start getting more and more tuples (hundreds of thousands) it starts to lag a bit, especially with more conditions added on top of this query.
So I want to put this query into a stored procedure to limit by dataset base on the timestamp before I do the additional queries.
I've tried this using oracle "views" and it works fine. However I need it to be a stored procedure I can call. I'm quite new to this stored procedure in oracle can someone show me how to port this simple query into a stored procedure in oracle?