Perchishka
8 years agoOccasional Contributor
JDBC request with date from another JDBC response and stored procedure
I have a JDBC response:
<Results> <ResultSet fetchSize="0"> <Row rowNumber="1"> <PS_SUBSCRIBE_DATA_290.CHANGED_DATE>2017-02-01 12:13:51.378</PS_SUBSCRIBE_DATA_290.CHANGED_DATE> </Row> </ResultSet> </Results>
I need to use this date in another JDBC request
But also ineed to use stored procedure because of the name of the table.
I have a SQL query for DBeaver client and it works:
select * from get_partition_name('ps_subscribe_history','2017-02-01 12:13:51'::timestamp without time zone)
But when i want to do the same sql query in JDBC request:
select * from get_partition_name('ps_subscribe_history', '${JDBC Request#ResponseAsXml#PS_SUBSCRIBE_DATA_290.CHANGED_DATE}')
This produces an error :
2017-02-01 18:46:34 - Error getting response; org.postgresql.util.PSQLException: ERROR: invalid input syntax for type timestamp: ""Position: 58
Could you help me to resolve this problem?
Maybe this error is caused by an incorrect date format ?
2017-02-01 12:13:51.378
Thank you, very much!
I did it!
assert context.ResponseasXML def parsedXml = new XmlSlurper().parseText(context.ResponseasXML) def dt = parsedXml.'**'.find { it.name() == 'PS_SUBSCRIBE_DATA_290.CHANGED_DATE'} as String def dd = dt.substring(0, dt.lastIndexOf(".")) log.info( dd ) context.testCase.setPropertyValue('CHANGED_DATE', dd)