Skip to Main Content
  • Questions
  • Structure of ANYTYPE in Java Stored Procedure

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Andrey.

Asked: March 14, 2020 - 2:58 pm UTC

Last updated: March 18, 2020 - 4:46 am UTC

Version: 12

Viewed 1000+ times

You Asked

Hello,

is there any way to construct a Structure of ANYTYPE using Java? There used to be class oracle.sql.STRUCT but it is now deprecated and not accepted in the code. The only alternative offered is "Use factory method Connection.createStruct to create an instance of java.sql.Struct directly." But this method needs name of type, so it seems, it is not possible to create structure of transient ANYTYPE.

Is this so, or do I miss some way?

Best regards
Andrey Voropaev

and Connor said...

Please take a look at this MOS note which talks about how to migrate

New JDBC Interfaces for Oracle types (Doc ID 1364193.1)

If that still does not help, please ping back here and I'll ask around in the Java/JDBC team

Rating

  (1 rating)

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

Comments

Extending description of the problem

Andrei, March 16, 2020 - 11:18 am UTC

Thank you for reference to the document. It confirmed my findings. Unfortunately it does not answer my question. I'll try to make it a bit clearer.

https://docs.oracle.com/cd/B19306_01/appdev.102/b14289/dcitblfns.htm describes Interface Approach and method "DESCRIBE" that can be used to describe result delievered by the table-function. I do have a way in PL/SQL to take variable of ANYTYPE and construct ANYDATASET in method FETCH. Now I'd like to do the same in Java. The offered factory method Connection.createStruct works only with named types. I can load ANYTYPE into TypeDescriptor, but it seems there is no way to create java.sql.Struct using TypeDescriptor.
Connor McDonald
March 18, 2020 - 4:46 am UTC

OK, I'll ask around internal and see what I can find out