in Education by
DROP TYPE Position; CREATE OR REPLACE TYPE Position AS OBJECT (longitude NUMBER(11,7), lattitude NUMBER(11,7), CONSTRUCTOR FUNCTION Position( long NUMBER, latt NUMBER ) RETURN SELF AS RESULT )FINAL; / CREATE OR REPLACE TYPE BODY Position AS CONSTRUCTOR FUNCTION Position( long NUMBER, latt NUMBER ) RETURN SELF AS RESULT IS BEGIN SELF.longitude := long; SELF.lattitude := latt; RETURN; END; END; / DESC Position; DROP TABLE District_Info; CREATE TABLE District_Info( Dname VARCHAR2(20), DPos Position, Boundary_dist VARCHAR2(20), Launch_ghat CHAR(1) ); DESC District_Info; INSERT INTO District_Info (Dname,DPos,Boundary_dist,Launch_ghat) VALUES ('d',Position(1.1, 1.1),'gr','y'); JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Your problem is that you have defined two constructors of the same type, but you didn't realize you did probably. When you create an object type, Oracle creates a default constructor, with parameters that match the parameters of the type. Therefore, when you also defined a constructor with only lattitude and longitude as inputs, Oracle cannot work out which constructor to call, the default created one, or your one, so it errors with: SQL Error: ORA-06553: PLS-307: too many declarations of 'POSITION' match this call To fix this, you can simplify your code: drop type position; CREATE OR REPLACE TYPE Position AS OBJECT (longitude NUMBER(11,7), lattitude NUMBER(11,7)) / DROP TABLE District_Info; CREATE TABLE District_Info( Dname VARCHAR2(20), DPos Position, Boundary_dist VARCHAR2(20), Launch_ghat CHAR(1) ); INSERT INTO District_Info (Dname,DPos,Boundary_dist,Launch_ghat) VALUES ('d',Position(1.1),'gr','y'); Ie, you don't need the constructor declaration or the body. If you like, you can have a DIFFERENT constructor, eg: CREATE OR REPLACE TYPE Position AS OBJECT (longitude NUMBER(11,7), lattitude NUMBER(11,7), -- Define a constructor that has only 2 parameters. CONSTRUCTOR FUNCTION position(i_longitude NUMBER) RETURN SELF AS RESULT ) / CREATE OR REPLACE TYPE BODY Position AS CONSTRUCTOR FUNCTION position(i_longitude NUMBER) RETURN SELF AS RESULT IS BEGIN SELF.longitude := i_longitude; SELF.lattitude := i_longitude; RETURN; -- self; END; END; / show errors; DROP TABLE District_Info; CREATE TABLE District_Info( Dname VARCHAR2(20), DPos Position, Boundary_dist VARCHAR2(20), Launch_ghat CHAR(1) ); DESC District_Info; INSERT INTO District_Info (Dname,DPos,Boundary_dist,Launch_ghat) VALUES ('d',Position(1.1),'gr','y');

Related questions

0 votes
    I am trying to run the query below select organization_id , listagg(secondary_inventory_name, ',') within group ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    how can i learn introduction c++ , simple c plus plus expression simple program if Select the correct answer from above options...
asked Dec 5, 2021 in Education by JackTerrance
0 votes
    how can i learn introduction c++ , simple c plus plus expression simple program if Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    I have to insert data in a table. It has a colum whose values should negative numbers like -1,-2 ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    The user defined data type can be created using (a) Create datatype (b) Create data (c) Create ... Answers, Database Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    I need to synchronize two tables. TableA Id Name TableB Id Name RefID --It's a Foreign key, defined as ... MATCHED BY TARGET THEN. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I need to synchronize two tables. TableA Id Name TableB Id Name RefID --It's a Foreign key, defined as ... MATCHED BY TARGET THEN. Select the correct answer from above options...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    When I insert the details in form and click on insert button, it shows "User has been added successfully ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    When I insert the details in form and click on insert button, it shows "User has been added successfully ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
0 votes
    When I insert the details in form and click on insert button, it shows "User has been added successfully ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    Commiting a code change, when the inspection fails , is perfectly fine as the code logic is working fine anyway (i)False (ii)True...
asked Oct 5, 2020 in Technology by Editorial Staff
0 votes
    I have a controller action as follows public function reportcommentAction() { $comment_id = $this->getRequest()- ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jan 16, 2022 in Education by JackTerrance
0 votes
    I've come to this code, but from this i have to manually insert all columns and check it by each ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    Select right statement to insert values in the table CUSTOMERS * a) INSERT VALUES INTO CUSTOMERS . b) INSERT INTO ... NONE OF THE ABOV Select the correct answer from above options...
asked Dec 24, 2021 in Education by JackTerrance
0 votes
    2- What values must be inserted in Insert table dialog box to create a table ? Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
...