Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- create or replace TYPE array_collection IS table OF VARCHAR2(50)
- --string array is working absolutely fine so dw about that
- create or replace type date_array is table of date;
- --here i don't if I've defined this array correctly
- create or replace procedure convert_arr(
- dat_ar in array_collection,perdate_arr out date_array)
- as
- begin
- perdate_arr:=new date_array();
- perdate_arr.extend(dat_ar.count);
- for i in 1..dat_ar.count loop
- perdate_arr(i):=to_date(dat_ar(i), 'yyyy-mm-dd');
- end loop;
- end convert_arr;
- --compiles perfectly
- set serveroutput on
- declare
- --l_dat array_collection;
- --l_darray date_array;
- l_dat array_collection:=array_collection();
- l_darray date_array:=date_array();
- begin
- l_dat := array_collection('2011-01-01','2011-04-01','2011-05-01');
- --l_dat.extend(3);
- -- l_dat(1):= to_date(2019-07-08);
- -- l_dat(2):= to_date(2019-07-09);
- -- l_dat(3):= to_date(2019-06-02);
- convert_arr(dat_ar=>l_dat,perdate_arr=>l_darray);
- dbms_output.put_line('Number of array:' || l_dat.count);
- for i in 1..l_dat.count loop
- dbms_output.put_line('Date ' || i || ':' || to_char(l_dat(i),'dd/mm/yyyy'));
- end loop;
- end;
- Error report -
- ORA-01861: literal does not match format string
- ORA-06512: at line 9
- 01861. 00000 - "literal does not match format string"
- *Cause: Literals in the input must be the same length as literals in
- the format string (with the exception of leading whitespace). If the
- "FX" modifier has been toggled on, the literal must match exactly,
- with no extra whitespace.
- *Action: Correct the format string to match the literal.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement