Last active
May 29, 2016 19:17
-
-
Save koenhendriks/eeb1ac0ddf70ba94f8e5a946c78f4b22 to your computer and use it in GitHub Desktop.
Oracle Query
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create or replace FUNCTION F_MEDIA | |
( | |
P_DATE IN VARCHAR2 DEFAULT 24-1-2013 | |
, P_INFLUENCE IN VARCHAR2 DEFAULT 'p' | |
, P_MEDIATYPE IN VARCHAR2 DEFAULT 'tv' | |
) RETURN NUMBER AS | |
CURSOR input is SELECT COUNT(CONTRACTS.CONTRACTDATE) | |
FROM CONTRACTS, MEDIA | |
WHERE | |
TO_CHAR(TO_DATE(P_DATE,'DD-MM-YYYY'), 'YYYY-MM-DD') = TO_CHAR(TO_DATE(substr(CONTRACTDATE, 0, 19),'YYYY-MM-DD HH24:MI:SS'), 'YYYY-MM-DD') | |
AND | |
MEDIA.INFLUENCE = P_INFLUENCE | |
AND | |
MEDIA.KIND = P_MEDIATYPE; | |
output number; | |
BEGIN | |
open input; | |
fetch input into output; | |
RETURN output; | |
END F_MEDIA; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment