Skip to Main Content
  • Questions
  • ORA-04065 when calling a method of a NON-INSTANTIABLE superclass

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Babak.

Asked: July 20, 2016 - 9:41 am UTC

Last updated: July 20, 2016 - 10:28 am UTC

Version: 12.1.0.2

Viewed 1000+ times

You Asked

Hi guys,

I've come across an issue when calling a method of a NON-INSTANTIABLE superclass.

You can find a sample script here: https://livesql.oracle.com/apex/livesql/file/content_DLRAPZYYKV51NA0FSUBU3RQ6W.html

We've got:
1. A non-Instantiable superclass called T_BASE, that has a function F_TEST which reveals the property of the object.
2. A subclass of T_BASE called T_SUB with a constructor which sets the property to 1 after instantiation.
3. An Object Type called T_OBJ which in turn receives an instance of T_SUB for instantiation, and reveals the t_sub object used for its instantiation through a public property called M_SUB.

Create the types (using the script above) and immediately run the following statement (on 12.1.0.2):

select t_obj(t_sub()).m_sub.f_test() from dual;

and you'll get:

ORA-04065: not executed, altered or dropped function ("No more data to read from socket" in 11.2.0.4!)

Now run the following statement:

select t_sub().f_test() from dual;

And afterwards rerun the first statement that lead to ORA-04065. As you can see, this time the statement doesn't fail!

However, if you disconnect the session, and connect again (do not use "reconnect" in SQL Developer), you'd see that the first SQL statement will again throw an ORA-04065.

We've noticed that if you move M_NUM and F_TEST to T_SUB, you will not come across the issue, so we believe that T_BASE being NON_INSTANTIABLE could be causing the problem.

Have we ignored a PL/SQL rule here? Are we doing something wrong? or is it a bug that we're dealing here?

Regards,
Babak.

and Chris said...

I can reproduce this on 12.1.0.2:

SQL> CREATE OR REPLACE TYPE T_BASE force IS OBJECT
  2  (
  3     M_NUM integer,
  4
  5     FINAL MEMBER FUNCTION F_TEST
  6     RETURN integer
  7  ) NOT INSTANTIABLE  NOT FINAL;
  8  /

Type created.

SQL> CREATE OR REPLACE TYPE BODY T_BASE
  2  AS
  3
  4     FINAL MEMBER FUNCTION F_TEST
  5     RETURN integer
  6     IS
  7     BEGIN
  8             RETURN M_NUM;
  9     END F_TEST;
 10
 11  END;
 12  /

Type body created.

SQL> CREATE OR REPLACE TYPE T_SUB force UNDER T_BASE
  2  (
  3    CONSTRUCTOR FUNCTION T_SUB
  4     RETURN SELF AS RESULT
  5  ) FINAL;
  6  /

Type created.

SQL> CREATE OR REPLACE TYPE BODY T_SUB
  2  AS
  3
  4     CONSTRUCTOR FUNCTION T_SUB
  5     RETURN SELF AS RESULT
  6     IS
  7     BEGIN
  8             SELF.M_NUM := 1;
  9             RETURN;
 10     END T_SUB;
 11
 12  END;
 13  /

Type body created.

SQL> CREATE OR REPLACE TYPE T_OBJ IS OBJECT
  2  (
  3     M_DUMMY integer,
  4     M_SUB T_SUB,
  5
  6     CONSTRUCTOR FUNCTION T_OBJ
  7     (
  8             P_SUB T_SUB
  9     )
 10     RETURN SELF AS RESULT
 11  ) NOT FINAL;
 12  /

Type created.

SQL> CREATE OR REPLACE TYPE BODY T_OBJ
  2  AS
  3
  4     CONSTRUCTOR FUNCTION T_OBJ
  5     (
  6             P_SUB T_SUB
  7     )
  8     RETURN SELF AS RESULT
  9     IS
 10     BEGIN
 11             SELF.M_DUMMY := 0;
 12             SELF.M_SUB := P_SUB;
 13             RETURN;
 14     END T_OBJ;
 15
 16  END;
 17  /

Type body created.

SQL> select t_obj(t_sub()).m_sub.f_test() from dual;
select t_obj(t_sub()).m_sub.f_test() from dual
             *
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04065: not executed, altered or dropped function


SQL> select t_sub().f_test() from dual;

T_SUB().F_TEST()
----------------
               1

SQL> select t_obj(t_sub()).m_sub.f_test() from dual;

T_OBJ(T_SUB()).M_SUB.F_TEST()
-----------------------------
                            1

On 11.2.0.4 I got an ORA-7445! So it's looking like a bug to me.

I'm not clear what the behaviour here should be though. In any case, I'd take this up with support.

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Super fast reply. Thanks.

Babak Tourani, July 20, 2016 - 10:35 am UTC


More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library