Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Java Stored Procedure and ClassCastException

Java Stored Procedure and ClassCastException

From: Kevin B <kbass1_at_nc-rr.com>
Date: Sat, 21 Jul 2001 23:51:51 GMT
Message-ID: <ecNU6.16779$ru2.6536912@typhoon.southeast.rr.com>

I am getting a ClassCastException error message when executing my Java Stored Procedure. After numerous times reviewing my code, I still cannot determine the cause of this problem. Assistance needed!

My code is as follows:



JAVA STORED PROCEDURE

create or replace and resolve java source named "LineItem" as
import java.sql.*;
import java.math.*;
import java.io.*;

import oracle.sql.*;

public class LineItem {
  public static BigDecimal logTransaction (STRUCT l) throws SQLException, ClassCastException {

    //Get the attributes of the customer object.       Object[] attribs = l.getAttributes();

    BigDecimal keyFinancial     = (BigDecimal)(attribs[0]);
    BigDecimal keyItem          = (BigDecimal)(attribs[1]);
    String subsubsystem         = (String)(attribs[2]);
    BigDecimal amount           = (BigDecimal)(attribs[3]);
    String userID               = (String)(attribs[4]);
    BigDecimal keyTransaction   = (BigDecimal)(attribs[5]);
    BigDecimal keyTxnAffinity   = (BigDecimal)(attribs[6]);
    BigDecimal keyItemAffinity  = (BigDecimal)(attribs[7]);
    String paymentType          = (String)(attribs[8]);
    BigDecimal microNumber      = (BigDecimal)(attribs[9]);
    String cardType             = (String)(attribs[10]);
    String cardNumber           = (String)(attribs[11]);
    String nameOnCard           = (String)(attribs[12]);
    Date expirationDate         = (Date)(attribs[13]);
    String productAccCode       = (String)(attribs[14]);
    BigDecimal unit             = (BigDecimal)(attribs[15]);

    return keyFinancial;
  }
}



CALLING PROGRAM

declare
  logtxn o_logtransaction :=
o_logtransaction(null,null,null,null,null,null,null,null,null,null,null,null ,null,null,null,null);
  hold2 number;

begin
  dbms_output.enable(1000000);

  logtxn.key_financial     := 111;
  logtxn.key_item          := 1;
  logtxn.subsystem         := 'TEST';
  logtxn.amount            := 1.99;
  logtxn.userID            := 'abc1';
  logtxn.key_transaction   := 12345;
  logtxn.key_txn_affinity  := 1;
  logtxn.key_item_affinity := 2;
  logtxn.payment_type      := 'CC';
  logtxn.micro_number      := 123456;
  logtxn.card_type         := 'VISA';
  logtxn.card_number       := 789011212;
  logtxn.name_on_card      := 'Herman Munster';
  logtxn.expiration_date   := '01-DEC-01';
  logtxn.product_acc_code  := 'LITTER';
  logtxn.unit              := 1;

  hold2 := LOG_TRANSACTION(logtxn);
  dbms_output.put_line('AND THE ANSWER IS : ' || hold2);

end;
/



PL/SQL

create or replace FUNCTION LOG_TRANSACTION (l o_logtransaction) RETURN NUMBER AS
  LANGUAGE JAVA
  NAME 'LineItem.logTransaction(oracle.sql.STRUCT) return BigDecimal';
/

Thanks,

Kevin Received on Sat Jul 21 2001 - 18:51:51 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US