Reputation: 11
I need to write a function to which I pass a date, and in response I receive records with the same date.
Table:
CREATE TABLE USERS(NAME VARCHAR, DATE_REG DATE);
INSERT INTO USERS(NAME, DATE_REG) VALUES ('TEST1', '01/01/2022'),('TEST2', '01/02/2022');
I am running a function:
SELECT * FROM TABLE(name_function(date '01/01/2022'));
Expecting to receive: 'TEST1', '01/01/2022'.
How to write a function?
What matters to me is that the function call was "SELECT * FROM TABLE(name_function(date '01/01/2022'));
" Script need for Oracle
Upvotes: 0
Views: 83
Reputation: 147
INSERT INTO USERS(NAME, DATE_REG) VALUES ('TEST1', TO_DATE('2003/07/09', 'yyyy/mm/dd'));
SELECT NAME, DATE_REG FROM USERS
WHERE
DATE_REG = TO_DATE('2003/07/09', 'yyyy/mm/dd');
So you should take your date as parameter then, get results from select and transform results to result table and return from function
Upvotes: 1