Type bug

jlcox

Member³
Given this piece of sample code:

Code:
CREATE OR REPLACE TYPE rectangle AS OBJECT
(
-- The type has 3 attributes.
  length NUMBER,
  width NUMBER,
  area NUMBER,
-- Define a constructor that has only 2 parameters.
  CONSTRUCTOR FUNCTION rectangle(length NUMBER, width NUMBER)
    RETURN SELF AS RESULT
);
/

CREATE OR REPLACE TYPE BODY rectangle AS
  CONSTRUCTOR FUNCTION rectangle(length NUMBER, width NUMBER)
    RETURN SELF AS RESULT
  AS
  BEGIN
    SELF.length := length;
    SELF.width := width;
-- We compute the area rather than accepting it as a parameter.
    SELF.area := length * width;
    RETURN;
  END;
END;
/
If I choose Types/New and create the spec and body and try to compile this, I get an error regarding the constructor name not matching the type name. However, If I switch the window type to Command, then it will compile successfully.
 
The problem is caused by the Program Window preference "Safe compilation". After disabling this option, compilation works correctly. We'll fix this bug.
 
Back
Top