Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Set parameter value

SainaaJun 15 2020 — edited Jun 16 2020

Hello I am trying to set default value for my parameter in procedure.

First it was something like this.

PROCEDURE arpu

(

P_DATE VARCHAR2 DEFAULT NULL

)

AS

v_date VARCHAR2(10);

BEGIN

IF(p_date IS NULL) THEN

v\_date := TO\_CHAR(sysdate-1,'yyyymmdd');

ELSE

v\_date := p\_date;

END IF;

Meaning if I insert parameter value from my hand it will run that day otherwise sysdate -1 like below.

BEGIN

pk_unv_report.arpu('20200614');

end;

Now I want to change parameter value to

procedure arpu

(

p_date varchar2 default null

)

as

v_date varchar2(10);

begin

if(p_date is null) then

v_date:=to_char(LAST_DAY(ADD_MONTHS(SYSDATE,-1)),'yyyymmdd');

else

 v\_date := p\_date ;

end if;

Meaning whether I insert parameter value or not it should run previous month last day value.

The problem is I seem to cant set p_date value to to_char(LAST_DAY(ADD_MONTHS(SYSDATE,-1)),'yyyymmdd')

It is giving me this error. Any solution for this one?

pastedImage_4.png

This post has been answered by mathguy on Jun 15 2020
Jump to Answer
Comments
Post Details
Added on Jun 15 2020
3 comments
2,751 views