I am trying to insert data in my table where one of the columns is of Object type, but I am getting the following error:
RA-06553: PLS-306: wrong number or types of arguments in call to 'SET_DATUME'
Table definition is:
CREATE TABLE Trebovanje (
BrDokumenta NUMBER,
Datumi DATUMI_T,
SifRJ NUMBER,
BrRadKnjiz NUMBER,
CONSTRAINT trebovanje_pk PRIMARY KEY (BrDokumenta),
CONSTRAINT treb_rj_fk FOREIGN KEY (SifRJ) REFERENCES RadnaJedinica (SifRJ),
CONSTRAINT trebovanje_zap_fk FOREIGN KEY (BrRadKnjiz) REFERENCES Zaposleni (BrRadKnjiz)
);
DATUMI_T user defined type:
create or replace TYPE DATUMI_T AS OBJECT (
DatPrijema DATE,
DatStampanja DATE,
MEMBER FUNCTION get_dat_prijema RETURN DATE,
MEMBER FUNCTION get_dat_stampanja RETURN DATE,
MEMBER PROCEDURE set_datume(p_dat_prijema DATE, p_dat_stampanja DATE),
MEMBER FUNCTION proveri_dat_stampanja(p_dat_stampanja DATE) RETURN BOOLEAN
);
create or replace TYPE BODY DATUMI_T AS
MEMBER FUNCTION get_dat_prijema RETURN DATE AS
BEGIN
RETURN self.DatPrijema;
END get_dat_prijema;
MEMBER FUNCTION get_dat_stampanja RETURN DATE AS
BEGIN
RETURN self.DatStampanja;
END get_dat_stampanja;
MEMBER PROCEDURE set_datume(p_dat_prijema DATE, p_dat_stampanja DATE) AS
BEGIN
self.DatPrijema := p_dat_prijema;
IF proveri_dat_stampanja(p_dat_stampanja)
THEN
self.DatStampanja := p_dat_stampanja;
ELSE
self.DatStampanja := SYSDATE;
END IF;
END set_datUME;
MEMBER FUNCTION proveri_dat_stampanja(p_dat_stampanja DATE) RETURN BOOLEAN AS
ok BOOLEAN;
BEGIN
ok := self.DatPrijema < p_dat_stampanja;
RETURN ok;
END proveri_dat_stampanja;
END;
And my insert statement:
insert into trebovanje values (
1,
DATUMI_T.set_datume(
TO_DATE('2017-01-02 17:44:33', 'YYYY-MM-DD HH24:MI:SS'),
TO_DATE('2017-01-02 17:55:33', 'YYYY-MM-DD HH24:MI:SS')
),
1,
1234);
Any thoughts on this?
What you seem to need is define a constructor that "hides" the default constructor.