First off, the INSERT_AGENCY_PROCEDURE
procedure is defined to take 8 parameters but you are trying to pass in 9 parameters. It appears that you are trying to pass in an AgencyLtrCode
but the procedure does not take an AgencyLtrCode
as a parameter. You would either have to stop trying to pass in the AgencyLtrCode
or you would need to modify the procedure to accept that parameter.
Second, you need to pass dates to the procedure given the declaration. Your actual procedure call will error out because what you are passing in for the date parameters are not dates (and cannot be implicitly converted to dates). Assuming that we eliminate the third parameter (which is what appears to be the AgencyLtrCode
discussed above), you would want something like
BEGIN
insert_AGENCY_Procedure(9003,
'Some Other Church',
'no',
to_date('10-10-2011', 'DD-MM-YYYY'),
to_date('10/10/2011', 'DD/MM/YYYY'),
to_date('10/10/2011','DD/MM/YYYY'),
17,
2 );
END;
Third, your procedure is incorrect. The parameters LASTLISTSENTDATA
, LETTERSENDDATE
, and CERTIFICATIONDATE
are defined as dates so you should not call to_date
on them. If you do, you force Oracle to implicitly convert the date to a string using the session's NLS_DATE_FORMAT
, then convert the string back to a date using the explicit format mask. That will fail if the session's NLS_DATE_FORMAT
is not what you expect.
Finally, declaring optional parameters in the middle of a procedure declaration is rarely correct. If you want to use positional binding and you want the ability to omit parameters, the optional parameters need to be at the end of the parameter list. You can define optional parameters in the middle of the parameter list and then use named binds (as DazzaL
demonstrates) but that is seldom what you want to force future developers to use.
In your updated procedure, the declaration of the AgencyLtrCode
parameter appears to be incorrect
AGENCYLTRCODE IN AGENCYLTRCODE%TYPE
needs to be
AGENCYLTRCODE IN AGENCY.AGENCYLTRCODE%TYPE
You are missing the name of the table.