I would like to know what data type should be in function return when a return value is an associative array in the following code:
create or replace FUNCTION GET_DAYS
(
DAY_IDS IN VARCHAR2 ,
FromDate IN Date,
Todate IN Date
) RETURN split_tbl /*SYS.ODCINUMBERLIST*/ AS
BEGIN
DECLARE
D_LIST split_tbl;
TYPE weekdays IS TABLE OF number INDEX BY PLS_INTEGER;
D_Date split_tbl:=split_tbl();
j number:=1;
m number:=1;
K NUMBER:=1;
weeks number:=1;
t_weeks number:=0;
u number;
wday char(3);
f_date date:=fromdate;
BEGIN
D_LIST := SPLIT2(DAY_IDS);
WHILE j <= D_LIST.count loop
u:=nvl(d_list(j),0);
select count(*) into m from days where (day_id)=u;
if m=1 then
select day into wday from days where (day_id)=u;
t_weeks:=(next_day(To_date(todate,'DD-Mon-RRRR'),wday)-next_day(To_date(f_date,'DD-Mon-RRRR'),wday))/7;
while (next_day(To_date(todate,'DD-Mon-RRRR'),wday)-next_day(To_date(f_date,'DD-Mon-RRRR'),wday))/7 >=1
loop
d_date.extend(nvl(t_weeks,0));
D_DATE(K):=to_char(weeks);
f_date:=f_date+7;
weeks:=weeks+1;
K:=K+1;
end loop;
end if;
j:=j+1;
END loop;
K:=0;
/*
while k<=d_date.count loop
d_date.extend(2000);
if(d_date(K)=null) then
d_date.delete(K);
end if;
end loop;
*/
RETURN D_Date;
END;
END GET_DAYS;
I am already using an associative array D_List that has been created of varchar2 but I need it in number.
CREATE OR REPLACE TYPE CUST_OBJ AS OBJECT (/* list of variables eg. myid number, myval varchar2(255) etc. */); CREATE OR REPLACE TYPE OBJ_TBL IS TABLE OF CUST_OBJ;. Then using the oci, make the custom collection ofOBJ_TBL, bind it, run query and fetch result.SYS.ODCINUMBERLIST(and decaringD_DATEto be that type)? What does theSPLIT2function do?