Reputation: 11
My code in Java calls stored procedure in Oracle DB and returns object with some fields. When I find out the attributes from the Object - I have problem with the string. The string becomes '???' (3 questtion marks) and it not supposed to be that! (integer returned OK)
I tested my stored procedure on the DB - It worked well.
I tested my Java code with small local main program that call to the DB - and it worked well. (The connection the the DB was direct with DriverManager.getConnection("jdbc:oracle:thin:@......); )
The problem came when I used my store procedure in my big project that connect to the DB with the weblogic.
Do you know how to get the right string from the DB when I work with the WebLogic?
Oracle code:
PROCEDURE SearchOrder (InWoArr IN WoTab,
OutWoAccStat OUT WoAccStatTab) as
outRec WoAccStatType;
wo number(10);
acc number(10);
stat varchar2(2);
begin
OutWoAccStat := WoAccStatTab();
for i in InWoArr.FIRST .. InWoArr.LAST loop
OutWoAccStat.EXTEND;
begin
select work_order_number,account_number,' '
into wo,acc,stat
from table1
where work_order_number=InWoArr(i);
....
outRec := WoAccStatType(wo,acc,stat);
OutWoAccStat(i) := outRec;
exception
when no_data_found then
outRec := WoAccStatType(InWoArr(i),0,' ');
OutWoAccStat(i) := outRec;
end;
end loop;
end SearchOrder;
//Array of 200
create or replace type poldev_dba.WoAccStatTab as VARRAY(200) of WoAccStatType
//The array type
create or replace type poldev_dba.WoAccStatType as object (work_order_number number(10), account_number number(10), wo_status varchar2(2))
//Java code:
//Store Procedure Name
CallableStatement cs = (CallableStatement) con.prepareCall("{ call spp.SearchOrder( ?, ? )}");
//input:
cs.setArray(1,woInput);
//Output:
cs.registerOutParameter(2,OracleTypes.ARRAY,"WOACCSTATTAB");
//Run the query...
cs.execute();
//Retrieve Array:
woAccArray = (ARRAY)cs.getArray(2);
woAccRecs = (Object[])woAccArray.getArray();
int wo = 0;
int acc = 0;
String stat;
for (int i = 0; i < woAccRecs.length; i++) {
/* Since we don't know the type of the record, get it into STRUCT !! */
STRUCT woAccRec = (oracle.sql.STRUCT)woAccRecs[i];
/* Get the attributes - nothing but the columns of the table */
Object[] attributes = woAccRec.getAttributes();
/* attribute 0 - work order */
wo = Integer.parseInt("" + attributes[0]);
/* attribute 1 - account number */
acc = Integer.parseInt("" + attributes[1]);
/* attribute 2 - status */
stat = (String) attributes[2];
/*PROBLEM!!!! stat returned value '???'*/
System.out.println("wo = " + wo + ",acc = " + acc +", status = "+stat);
Upvotes: 1
Views: 2686
Reputation: 328750
The problem is elsewhere. Neither the Oracle DB nor the DB driver will replace a result column with ???
. Search the code of your product for this string to see why it is used.
Upvotes: 0