Aufrufen von gespeicherten oracle-Prozedur mit der Feder gespeicherte Prozedur
Habe ich versucht, um ein Stück code, spring verwendet und in oracle gespeicherten Prozedur mit Parametern, aber finden es schwierig, zu führen. Die gespeicherte Prozedur, wie angegeben, bestimmt ist zu erwarten, dass drei parameter, aber in der Fehlermeldung scheint es, es rechnet vier. Der vierte parameter ist ein cursor zurückgegeben werden.
Hier ist mein Oracle(9i) - Paket-Spezifikation:
CREATE OR REPLACE PACKAGE pkg_data_load AS
procedure sp_atm_withdrawal(p_catermid IN VARCHAR2,
p_start_date IN VARCHAR2,p_end_date IN VARCHAR2,p_out out sys_refcursor);
END;
Unten ist das Paket, Karosserie:
CREATE OR REPLACE PACKAGE BODY pkg_data_load
AS
procedure sp_atm_withdrawal
(
p_catermid IN VARCHAR2,
p_start_date IN VARCHAR2,
p_end_date IN VARCHAR2,
p_out out sys_refcursor
) as
v_start_date date := to_date(p_start_date,'yyyy/mm/dd');
v_end_date date := to_date(p_end_date,'yyyy/mm/dd');
begin
open p_out for select
b.nam_branch BRANCH_NAME
, a.bcode brn_Code
, a.acct_no Acct_no
from table a, table b where b.cod_Cc_brn= a.cod_org_brn
and a.cod_reply=0
and b.flg_mnt_status='A'
and a.cod_proc not in ( 312000, 382000, 311000, 381000)
and a.cod_txn_literal<>'SCD'
and a.ca_term_id in (
select ca_term_id from tablec where flg_mnt_status='A')
and a.dat_post_stl between v_start_date and v_end_date
and a.ca_term_id = p_catermid;
end sp_atm_withdrawal;
END pkg_data_load;
Hier ist ein Ausschnitt von meinem Verfahren Klasse
public class AtmStoredProcedures extends StoredProcedure {
public AtmStoredProcedures(JdbcTemplate jdbcTemplate, String procedure)
{
super(jdbcTemplate,procedure);
AtmRowMapper rowMapper = new AtmRowMapper();
declareParameter(new SqlOutParameter("sys_refcursor",OracleTypes.CURSOR, rowMapper));
declareParameter(new SqlParameter("branch", Types.VARCHAR));
declareParameter(new SqlParameter("startDate", Types.VARCHAR));
declareParameter(new SqlParameter("endDate", Types.VARCHAR));
compile();
}
public Map getCashWithdrawals(String branch, String startDate, String endDate)
{
Map inParam = new HashMap();
inParam.put("branch", branch);
inParam.put("startDate", startDate);
inParam.put("endDate", endDate);
Map out = execute(inParam); //Call on parent class
return out;
}
}
Und Unten ist mein DAO-Implementierung Methode
public List<Atm> loadWithdrawal(String branch, String startDate, String endDate) {
if (this.jdbcTemplate == null) {
System.out.print("JDBC TEMPLATE IS NULL");
}
List<Atm> withdrawals = null;
try
{
AtmStoredProcedures st = new AtmStoredProcedures(jdbcTemplate,"pkg_data_load.sp_atm_withdrawal");
Map results = st.getCashWithdrawals(branch, startDate, endDate);
withdrawals = (List<Atm>) results.get("sys_refcursor");
} catch (DataAccessException ex) {
System.out.print(ex.getMessage());
}
return withdrawals;
}
Nach erfolgreicher compliation bekomme ich die folgenden Fehlermeldung zur Laufzeit
CallableStatementCallback; bad SQL grammar
[{call pkg_data_load.sp_atm_withdrawal(?, ?, ?, ?)}];
nested exception is java.sql.SQLException:
ORA-06550: line 1, column 7: PLS-00306: wrong number or
types of arguments in call to 'SP_ATM_WITHDRAWAL'ORA-06550:
line 1, column 7: PLS-00306: wrong number or types of arguments
in call to 'SP_ATM_WITHDRAWAL'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
InformationsquelleAutor Ololade enifeni | 2012-09-21
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ihre Anrufe zu declareParameter() müssen in der gleichen Reihenfolge wie die Oracle-gespeicherten Prozedur. Versuchen Sie dies:
InformationsquelleAutor GriffeyDog
erstellen Sie eine bean für die datasource-Konfiguration:
Erstellen einer dao-mit Verweis auf die Sie injizieren Ihre datasource - (applicationContext.xml):
Dann erstellen Sie eine Klasse für convert Oracle-Array an die java-Liste
Dann erstellen TestDao zu call-Verfahren::
InformationsquelleAutor Ravi Kant