Forum Stats

  • 3,780,546 Users
  • 2,254,409 Discussions
  • 7,879,379 Comments

Discussions

Unable to insert row with calling stored procedure in ADF

Okan Sutcuoglu
Okan Sutcuoglu Member Posts: 121 Red Ribbon
edited Oct 16, 2018 8:16AM in JDeveloper and ADF

Hi everyone. I use JDeveloper 12.2.1.3 and JDK 1.8.171

I looked this thread over here : how to call a stored procedure in ADF

I did the same think and i succeded.

But when i try to add an insert code or delete code in the procedure like:

CREATE or REPLACE PROCEDURE SP_HELLOWORLD

(

  NAME IN VARCHAR2

, WISHES OUT VARCHAR2

) AS

BEGIN

WISHES:= 'Hello '||name||', Welcome to SP. ';

INSERT INTO EMPLOYEES VALUES(300,'Okan','Sutcuoglu','OSUTCUOGLU','650.507.9833',SYSDATE,'FI_MGR',200,null,124,50);

END SP_HELLOWORLD;

It does not insert or delete any row.

When i run just the insert code it inserts the row but in the procedure it does not.

I call the procedure in the appmoduleimpl like :

        try {

            System.out.println("***************** Start of code ****************");

            String sql = "begin SP_HELLOWORLD(:NAME,:WISHES); end; ";

            CallableStatement st = getDBTransaction().createCallableStatement(sql, getDBTransaction().DEFAULT);

            st.setObject("NAME", "ABC"); // replace with required param

            st.registerOutParameter("WISHES", Types.VARCHAR); //import java.sql.Types;

            st.execute();

            System.out.println(" The output of the DB function is : " + st.getObject("WISHES"));

            System.out.println("***************** End of code ****************");

        } catch (Exception e) {

            e.printStackTrace();

        }

It returns me 

***************** Start of code ****************

The output of the DB function is : Hello ABC, Welcome to SP.

***************** End of code ****************

But does not insert the row.

Tagged:

Best Answer

Answers