I am using ojdbc6.jar. I created a preparedStatement with the sql query (insert statement from local db to remote db using dblink) having a subquery in from condition. I am setting a string parameter in the subquery and double parameter in the outside query. When I call, preparedStatemet.executeUpdate() or execute() or executeQuery(), it is resetting the String parameter to null and then running the result query in database. My query will be look like this:
String stmt = Insert into table1@dblink select table1.col1, table1.col2 from table1 table1, (select table1.pkcol1 from table1 table1, jointable jointable where jointable.seqid = table1.pkcol1 and jointable.name = ?) OrigQry where table1.pkCol1 = OrigQry.pkCol1 and OrigQry.pkCol1 = ?;
pstmt.executeUpdate(); -- This should return me the number of rows that got updated/inserted. But it is always saying giving me 0 output.
When I run the same query in sqlplus I am able to insert one row.
When I debugged this, I found out that oraclepreparedsatement is resetting my string parameter to 'null' from 'NAME' on call of executeUpdate(). I tried to use execute() and executeQuery() also. They are also behaving in same manner.