I want to send two arrays form java to oracle stored procedures. The first Array is array of strings and the second is array of chars how can I make this??
PeudoCode for the same how I achieved.
# 1.You will require a structDescriptor object for an object equivalent in pl sql like :
StructDescriptor structDes= new StructDescriptor(".", connectionObject);
# 2. You will need to pass one object values such name, class, id to an object array in order and accordance to 'sql_object_name' object.
For exmaple:
STRUCT[] structArray=new STRUCT[.size()];
int index=0;
for (a in ListObj){
Object[] object=new Object[]{a.getName(),a.getId()};
STRUCT struct=new STRUCT(structDes ,connectionObject,object);
structArray[index]=struct;
index++;
}
ArrayDescriptor arrayDes=ArrayDescriptor.createDescriptor(
".", connectionObject);
ARRAY array=new ARRAY(arrayDes,connectionObject, structArray);
then pass it to proc
.declareParameters(
new SqlInOutParameter("",OracleTypes.ARRAY,"
."))
like
Hashmap map= new HashMap<>();
map.put("",array);
psStatement.execute(map);
Hope it helps. This sequence may vary as per requirement and type of sql database used, but base is same.
I have copied this answer from one of my other answers.
Pass array as input parameter to an oracle stored procedure using simple jdbc call
- 热议问题