Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. create or replace TYPE array_collection IS table OF VARCHAR2(50)
  2. --string array is working absolutely fine so dw about that
  3.  
  4. create or replace type date_array is table of date;
  5. --here i don't if I've defined this array correctly
  6.  
  7. create or replace procedure convert_arr(
  8. dat_ar in array_collection,perdate_arr out date_array)
  9. as
  10. begin
  11. perdate_arr:=new date_array();
  12. perdate_arr.extend(dat_ar.count);
  13. for i in 1..dat_ar.count loop
  14. perdate_arr(i):=to_date(dat_ar(i), 'yyyy-mm-dd');
  15. end loop;
  16. end convert_arr;
  17. --compiles perfectly
  18.  
  19. set serveroutput on
  20. declare
  21. --l_dat array_collection;
  22. --l_darray date_array;
  23. l_dat array_collection:=array_collection();
  24. l_darray date_array:=date_array();
  25. begin
  26. l_dat := array_collection('2011-01-01','2011-04-01','2011-05-01');
  27. --l_dat.extend(3);
  28. -- l_dat(1):= to_date(2019-07-08);
  29. -- l_dat(2):= to_date(2019-07-09);
  30. -- l_dat(3):= to_date(2019-06-02);
  31.  
  32. convert_arr(dat_ar=>l_dat,perdate_arr=>l_darray);
  33. dbms_output.put_line('Number of array:' || l_dat.count);
  34. for i in 1..l_dat.count loop
  35. dbms_output.put_line('Date ' || i || ':' || to_char(l_dat(i),'dd/mm/yyyy'));
  36. end loop;
  37. end;
  38.  
  39. Error report -
  40. ORA-01861: literal does not match format string
  41. ORA-06512: at line 9
  42. 01861. 00000 - "literal does not match format string"
  43. *Cause: Literals in the input must be the same length as literals in
  44. the format string (with the exception of leading whitespace). If the
  45. "FX" modifier has been toggled on, the literal must match exactly,
  46. with no extra whitespace.
  47. *Action: Correct the format string to match the literal.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement