I am using 11g
I have table
CREATE TABLE Agency
(
AgencyID int not null PRIMARY KEY,
AgencyName VARCHAR2(30) not null,
AgencyLtrCode VARCHAR2(10) not null,
IsActive VARCHAR2(3) DEFAULT 'yes'NOT NULL,
LastListSentData DATE DEFAULT SYSDATE ,
LetterSendDate DATE DEFAULT SYSDATE ,
CertificationDate DATE DEFAULT SYSDATE ,
CeresNo int,
AgencyAreaID int not null,
CONSTRAINT fk_Agency FOREIGN KEY (AgencyAreaID) REFERENCES AgencyArea(AriaID)
);
I use procedure to insert new records in it
create or replace PROCEDURE insert_AGENCY_Procedure(
AGENCYID IN AGENCY.AGENCYID%TYPE,
AGENCYNAME IN AGENCY.AGENCYNAME%TYPE,
AGENCYLTRCODE IN AGENCY.AGENCYLTRCODE%TYPE,
ISACTIVE IN AGENCY.ISACTIVE%TYPE DEFAULT 'yes',
LASTLISTSENTDATA IN AGENCY.LASTLISTSENTDATA%TYPE DEFAULT SYSDATE,
LETTERSENDDATE IN AGENCY.LETTERSENDDATE%TYPE DEFAULT SYSDATE,
CERTIFICATIONDATE IN AGENCY.CERTIFICATIONDATE%TYPE DEFAULT SYSDATE,
CERESNO IN AGENCY.CERESNO%TYPE,
AGENCYAREAID IN AGENCY.AGENCYAREAID%TYPE)
IS BEGIN
INSERT INTO AGENCY("AGENCYID", "AGENCYNAME","AGENCYLTRCODE","ISACTIVE","LASTLISTSENTDATA","LETTERSENDDATE","CERTIFICATIONDATE","CERESNO","AGENCYAREAID")
VALUES (AGENCYID, AGENCYNAME,AGENCYLTRCODE,ISACTIVE,LASTLISTSENTDATA,LETTERSENDDATE,CERTIFICATIONDATE,CERESNO,AGENCYAREAID);
COMMIT;
END;
right now it throw error “Error at line 17: PLS-00103: Encountered the symbol “” ”
line 17 had only END; on it
when I submit inserting which looks like
BEGIN
insert_AGENCY_Procedure(9003,'Some Other Church', 'SomOTCh','no',10-10-2011,10/10/2011,10/10/2011,17,2 );
END;
it throws error
ORA-06550: line 2, column 4:
PLS-00306: wrong number or types of arguments in call to 'INSERT_AGENCY_PROCEDURE'
ORA-06550: line 2, column 4:
PL/SQL: Statement ignored
or other insert like
BEGIN
insert_AGENCY_Procedure(9003,'Some Other Church',SomOTCh',DEFAULT,DEFAULT,DEFAULT,DEFAULT,17,2 );
END;
it throws error
ORA-06550: line 2, column 64:
PLS-00103: Encountered the symbol "DEFAULT" when expecting one of the following:
( - + case mod new not null
The question is what is wrong with my procedure? I was trying to resolve this problem but stuck 🙁
First off, the
INSERT_AGENCY_PROCEDUREprocedure is defined to take 8 parameters but you are trying to pass in 9 parameters. It appears that you are trying to pass in anAgencyLtrCodebut the procedure does not take anAgencyLtrCodeas a parameter. You would either have to stop trying to pass in theAgencyLtrCodeor 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
AgencyLtrCodediscussed above), you would want something likeThird, your procedure is incorrect. The parameters
LASTLISTSENTDATA,LETTERSENDDATE, andCERTIFICATIONDATEare defined as dates so you should not callto_dateon them. If you do, you force Oracle to implicitly convert the date to a string using the session’sNLS_DATE_FORMAT, then convert the string back to a date using the explicit format mask. That will fail if the session’sNLS_DATE_FORMATis 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
DazzaLdemonstrates) but that is seldom what you want to force future developers to use.In your updated procedure, the declaration of the
AgencyLtrCodeparameter appears to be incorrectneeds to be
You are missing the name of the table.