Typeof Equivalent for Object Types in PL / SQL

I am trying to use OOP and TDD inside Oracle. Yes, I know it sounds crazy. And I need advice.

I am writing a test for the following constructor method (simplified for the purposes of this question):

CONSTRUCTOR FUNCTION PERSON(p_pidm NUMBER, p_throw_exception NUMBER DEFAULT 0, p_program_id NUMBER DEFAULT 0)
RETURN SELF AS RESULT IS

BEGIN

    -- Attach constructor parameters to internal attributes
    self.throw_exception := p_throw_exception;
    self.program_id := p_program_id;

    -- TESTING STUDENT INSTANTIATION
    self.student := NEW STUDENT(self.a_pidm);

    RETURN;
END;

      

In a related test, I need to verify that is self.student

set to a valid instance STUDENT

. In other languages, I do this with the typeof method, but I am not aware of this in PL / SQL.

So the question is, does anyone know a function / procedure so that I can pass in a custom type and return its class / type name?

Thank.

+3


source to share


1 answer


You might want to use the syntax IS OF <<type>>

.

Something like



IF l_variable IS OF( student )
THEN
  <<do something>>
END IF;

      

+5


source







All Articles