I have complex procedures in oracle package with complex in/out parameters. I will show one of the my procedures in following :

 PROCEDURE Authorize(PO_ErrorCode         OUT NUMBER,
                     PO_ErrorText         OUT VARCHAR2,
                     PI_Count             IN NUMBER,
                     PI_Setting           IN Setting,
                     PI_InputData         IN InputData,
                     PO_PreData           OUT InputData);

and will show two structures Setting and InputData in following:

CREATE OR REPLACE TYPE Setting as object( ProviderType  NUMBER
                                          SwitchCode    NUMBER)

CREATE OR REPLACE TYPE Input_Data Is Table Of MainInputData;

CREATE OR REPLACE TYPE MainInputData as object( itemId            NUMBER,
                                                itemValue         NVARCHAR2(150),
                                                itemEncyptd       NUMBER,
                                                itemEncryptKey    RAW(16));

with above description I have several structure contain : Type, Array, Array of Type and Array of Primitive.

I call this function by jdbc and oracle driver and related classes such as STRUCT& ARRAY but generated a lot of and complex code for this goal.

My question is : Is there utility or framework for do this task by simple code? I know spring has a jdbc utility but I haven't experience with it.

有帮助吗?

解决方案

You can use spring utility.

There is a class StoredProcedure where can you declare all your input and output parameters and their types inside the constructor using sqlOutParameter and sqlInParameter.

In your case there are 3 input parameters, to pass this you can overwrite execute method with 3 arguments and call

super.execute(a,b,c)

This link will be helpful.

其他提示

We have internal utility which does exactly what you need. It generates:

  • JPA entities based on Oracle Object Types and extended with eclipselink specific annotations.
  • Java interfaces reflecting PL/SQL package.

In the runtime eclipselink translates the entity instances into java.sql.Struct instances, and call to generated java interface is intercepted by our runtime which dynamically invokes PL/SQL procedures and functions. It also supports IN/OUT parameters and allows to expose PL/SQL packages as webservices. It eases our development where we have lots of hierarchical Oracle Object Types. I wish it was publicly available. If your are interested in the tool, please contact me.

You can also use Oracle's jpublisher for this purpose:

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top