Call Oracle Stored Procedure using JDBC CallableStatement
Calling stored procedure is same as calling stored function as mentioned in previous post. In this example we will perform INSERT, UPDATE, DELETE on Account table. Code snippets to show you how to call a Oracle stored procedure via JDBC CallableStatement , and how to pass IN parameters from Java to stored procedure. 1) Stored Procedure A stored procedure in Oracle database. Later, calls it via JDBC. create or replace procedure spAccount(p_acode number,p_aname varchar, p_obalance number,p_descflag varchar) IS begin --INSERTING METHOD IF p_descflag = 'I' THEN insert into account values (p_acode,p_aname,p_obalance); END IF; --UPDATING METHOD IF p_descflag = 'U' THEN update account aa set aa.acct_name = p_aname, aa.obalance = p_obalance where aa.acct_code = p_acode; END IF; --UPDATING METHOD IF p_descflag = 'D' THEN delete from account aa where aa.acct_code = p_acode; END IF; commit; end spAccount; ...