如何将带有数组属性的struct从Java传递给SQL存储过程?

时间:2022-01-24 08:51:11

I have some types in Oracle.

我在Oracle中有一些类型。

create or replace
TYPE r_telefone_cand AS OBJECT (
    candidato NUMBER(10,0),
    telefone VARCHAR2(15)
);

create or replace TYPE t_telefone_cand AS TABLE OF r_telefone_cand;

create or replace
TYPE r_candidato AS OBJECT (
    codigo NUMBER(10,0),
    rg VARCHAR2(15),
    cpf NUMBER(15,0),
    nome VARCHAR2(50),
    telefone t_telefone_cand,
);

And I have an procedure insert_candidato that parameter IN is candidato r_candidato

我有一个过程insert_candidato,参数IN是candidato r_candidato

create or replace
PROCEDURE insert_candidato(
    candidato IN r_candidato
) AS ...

But I don't know how to pass the parameter candidato with the colletion telefone.

但我不知道如何通过收集电话传递参数candidato。

Pleae, help me.

请帮助我。

2 个解决方案

#1


1  

Give a try using JPublisher of Oracle.. !

尝试使用Oracle的JPublisher ..!

http://download.oracle.com/docs/cd/B10500_01/java.920/a96658/intro.htm

It helps in interacting with user defined DB objects through Java.

它有助于通过Java与用户定义的DB对象进行交互。

#2


1  

You can use SQLData to map a java class to an oracle User Defined type. Check out the docs at http://download.oracle.com/javase/1.4.2/docs/api/java/sql/SQLData.html

您可以使用SQLData将java类映射到oracle用户定义类型。查看http://download.oracle.com/javase/1.4.2/docs/api/java/sql/SQLData.html上的文档

In your case you'd need two types to match the db types.

在您的情况下,您需要两种类型来匹配数据库类型。

#1


1  

Give a try using JPublisher of Oracle.. !

尝试使用Oracle的JPublisher ..!

http://download.oracle.com/docs/cd/B10500_01/java.920/a96658/intro.htm

It helps in interacting with user defined DB objects through Java.

它有助于通过Java与用户定义的DB对象进行交互。

#2


1  

You can use SQLData to map a java class to an oracle User Defined type. Check out the docs at http://download.oracle.com/javase/1.4.2/docs/api/java/sql/SQLData.html

您可以使用SQLData将java类映射到oracle用户定义类型。查看http://download.oracle.com/javase/1.4.2/docs/api/java/sql/SQLData.html上的文档

In your case you'd need two types to match the db types.

在您的情况下,您需要两种类型来匹配数据库类型。