Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to access Oracle object?

JackKAug 16 2021

Hi!

create or replace type t_test as object (
  n1 number(1),
  n2 number(2)
);

SELECT sq.* from (
  with d(tp) as (
  SELECT t_test(1, 11) FROM dual UNION ALL
  SELECT t_test(2, 12) FROM dual UNION ALL
  SELECT t_test(3, 13) FROM dual
)
SELECT * FROM d) sq;

When using JDBC, how may Java programmer access the returned data?
I have information from my colleague that there is no TP.N1 or TP column in the result.
I don't want to use

SELECT sq.tp.n1 AS n1, sq.tp.n2 AS n2 from (
  with d(tp) as (
  SELECT t_test(1, 11) FROM dual UNION ALL
  SELECT t_test(2, 12) FROM dual UNION ALL
  SELECT t_test(3, 13) FROM dual
)
SELECT * FROM d) sq;

because this takes much more time to execute, when there is more object's attributes.
Regards,
Jacek

Comments
Post Details
Added on Aug 16 2021
1 comment
184 views