SELECT— DAY LEVELtime_id AS day_id,INITCAP(TO_CHAR(time_id,’fmMonth DD, YYYY’)) AS day_desc,INITCAP(TO_CHAR(time_id, ‘fmDAY’)) AS day_name,TO_NUMBER(TO_CHAR(time_id – 1, ‘D’)) AS day_of_week,TO_NUMBER(TO_CHAR(time_id, ‘DD’)) AS day_of_month,TO_NUMBER(TO_CHAR(time_id, ‘DDD’)) AS day_of_year,1 AS days_in_day, — MONTH LEVELTO_CHAR(time_id, […]
Check the database user session details
v$session Using v$session you can list all sessionsidentify active sessions with STATUS=’ACTIVE’ and how long it was running LAST_CALL_ET see running sql with SQL_ID or SQL_ADDRIf session is […]
Exclude Days SQL Function
create or replace FUNCTION EXCLUDE_WEEKEDNDS (p_start_date IN date, p_end_date IN date)RETURN NUMBERISl_count NUMBER;BEGINl_count := 0;SELECT COUNT(1) INTO l_countFROM(WITH DATA AS(SELECT–to_date(trunc(p_start_date), ‘YYYY-MM-DD’) date1,–to_date(trunc(p_end_date), ‘YYYY-MM-DD’) date2p_start_date date1,p_end_date date2FROM dual)SELECT date1+LEVEL-1 […]
Oracle SQL Function with Examples
PL/SQL function is a reusable program unit stored as a schema object in the Oracle Database. The following illustrates the syntax for creating a function: CREATE [OR REPLACE] […]