Not able to use update query in data sink- ReadyAPI
Not able to use update query in data sink. It always throws error "java.lang.exception:SQL error occured".
Below is the query i am using(MySql DB):
update table_out set status="Trans" where destination="12568"
Currently i am blocked due to this. Please help!
Hi Ready4API
ok - I've just been reading the help on this datasink - as I mentioned before - I've never used a datasink (JDBC or DataConnection) step to update a database before - I've just used the JDBC test step instead. The help instructions for a JDBC or DataConnection datasink (link) and they state as follows:
"Specifies the query to the database. You can specify the desired query manually or by using the Build SQL
Query or Create Query dialog. To insert test step property values into the query, use a question mark (?). The values will be used in the
order they are specified on the property list on the left. Property expansion does not work in the query. Use a question mark (?) to insert values instead. You can read more about working with SQL queries below."It states you can't use property expansions in there - which is I assume why you need to specify those properties. Also - you need to specify the properties in order in which they should be used in the query (which are represented in the query using '?' marks).
so if I understand correctly if your query is as follows:
update test_out set status=statusValue where destination=destValue
you need to create 2 properties (status = ${DataSink#status} and destination = {DataSink#destination}) and alter your query so it reads as follows:
update test_out set status=? where destination=?
n.b. - the properties need to be specified in the correct order according to the help.
Is there a reason why you need to use the datasink step to update the database? The reason I ask is that the normal JDBC step (not the Data Sink step) allows property expansions (cos I use them all the time) and the JDBC test step still supports all DML command (update, insert, merge, delete) - if I were you - I'd use the JDBC test step and save all the hassle.
Cheers,
rich