Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

oracle search

Friday, August 8, 2008

Two days before the day after tomorrow ....oracle

Clearly a South Park fan worked here once:

cat oracle_GetThisworkingDay

DATE=`date +%Y%m%d%H%M`
CUTOFF=$2

#!/bin/ksh
# oracle_GetThisworkingDay
# Script to retrieve the current working day (YYYYMMDD) from
# the working_calendar table in the Oracle database.
oracle_GetPreviousWorkingDay `oracle_GetNextWorkingDay $DATE $CUTOFF`

I'll spare you the contents of these scripts. Suffice to say they call the following procedures:
   FUNCTION previous_day (
p_date DATE DEFAULT SYSDATE
)
RETURN VARCHAR2
IS
v_result VARCHAR2 (10);
BEGIN
SELECT dt
INTO v_result
FROM working_calendar
WHERE dt = (SELECT MAX (dt)
FROM working_calendar
WHERE dt < p_date );
RETURN TO_CHAR(v_result,'YYYYMMDD');
END;
( nice use of SQL there ) and of course...
   FUNCTION next_day (
p_now DATE DEFAULT CURRENT_DATE
)
RETURN DATE
IS
RESULT DATE;
BEGIN
SELECT MIN (dt)
INTO RESULT
FROM working_calendar
WHERE dt >= p_now + 1;

RETURN RESULT;
END;

No comments: