1

I have a plsql-Script. When I run it on sqldeveloper it works fine.

But when I run it in spring boot jdbctemplate:

jdbcTemplate.execute(Sql); 

It doesn't update in db.

plsql sample

BEGIN
    UPDATE cust_txcutover_uda
        SET TX_CUTOVER_COMMENTS =
            SUBSTR ('aa/bb', 1, INSTR ('aa/bb', '/') - 1)
        WHERE CUST_TXCUTOVER_UDA_ID = '1373';

    COMMIT;
END;

I can't find the reason for that, how can I run plsql with jdbctemplate?

Victor
  • 3,669
  • 3
  • 37
  • 42
Yousef Al Kahky
  • 703
  • 1
  • 8
  • 23
  • 1
    Possible duplicate of [Spring JDBC Template for calling Stored Procedures](https://stackoverflow.com/questions/9361538/spring-jdbc-template-for-calling-stored-procedures) – Simon Martinelli Feb 04 '19 at 11:37
  • Is this pl/sql a stored procedure in the data base? if this is the case, you can use SimpleJdbcCall. If not... wouldn't it be easier make it via java? – Jose Luis Feb 04 '19 at 13:06
  • Wild guess: The semicolon at the end of your script has to be removed. I don't know much about java, but most time you have to execute a single statement (in this case "BEGIN ... END"). Because of this a semicolon to introduce a second one is not allowed. Beside this: Yevhens answer is corret. You don't need plsql. Just run the update. – kara Feb 04 '19 at 14:02

1 Answers1

2

As I know jdbcTemplate.execute doesn't support execution of anonymous PL/SQL block. Try execute just

UPDATE cust_txcutover_uda
   SET TX_CUTOVER_COMMENTS = SUBSTR ('aa/bb', 1, INSTR ('aa/bb', '/') - 1)
 WHERE CUST_TXCUTOVER_UDA_ID = '1373'

without wrap it by begin and end