I am trying to create a function. When a record comes in it and is processed We need to calculate the last date of the previous month. That works but when I try to put it in a function so I can pass that date to another program on compile I get the message: ORA-00922 missing or invalid option. I have tried numerous things. I am not a programmer however all of our developers are buried so they gave this to me. Any help I get is appreciated. Below is my code:
set serveroutput on
create or replace
function date_function(v_out in VARCHAR2, v_date in DATE)
return CHAR
-- 1
select trunc(sysdate, 'mon') -1 from dual;
-- 2
declare
v_date date;
v_out varchar2(10);
begin
v_date := to_date('20100820', 'yyyymmdd');
v_out := to_char(trunc(v_date, 'mon') -1, 'mm/dd/yyyy');
dbms_output.put_line(to_char(v_date, 'mm/dd/yyyy'));
dbms_output.put_line(v_out);
return v_out;
end;
Cretin
set serveroutput on
create or replace
function date_function(v_out in VARCHAR2, v_date in DATE)
return CHAR
-- 1
select trunc(sysdate, 'mon') -1 from dual;
-- 2
declare
v_date date;
v_out varchar2(10);
begin
v_date := to_date('20100820', 'yyyymmdd');
v_out := to_char(trunc(v_date, 'mon') -1, 'mm/dd/yyyy');
dbms_output.put_line(to_char(v_date, 'mm/dd/yyyy'));
dbms_output.put_line(v_out);
return v_out;
end;
Cretin