I have a view in my DBM that looks like this:
SELECT CDN, DN_GRUPPE, AFSLUTTET_AF AS INITIALS, AGENTGRUPPE AS AGENTGROUP, STATUS, CREATED, LAST_UPD , TRUNC(LAST_UPD)- TRUNC(CREATED) AS SOLVED_SECONDS
FROM [email protected] LEFT JOIN KS_DRIFT.SYS_DATE_KS AA ON TO_DATE(TRUNC(LAST_UPD),'YYYY-MM-DD') = AA.THIS_DATE
WHERE TIDSPUNKT > (SYSDATE - 427)
When my Java application tries to get the selected column SOLVED_SECONDS it returns the values as it should.
HOWEVER if I alter the view to the following:
SELECT CDN, DN_GRUPPE, AFSLUTTET_AF AS INITIALS, AGENTGRUPPE AS AGENTGROUP, STATUS, CREATED, LAST_UPD , CASE WHEN CALCULATE_CALLBACK_DURATION(CREATED,LAST_UPD) is NULL THEN
CALCULATE_CALLBACK_DURATION(AA.THIS_DATE_OPENING, LAST_UPD) ELSE
CALCULATE_CALLBACK_DURATION(CREATED, LAST_UPD) END AS SOLVED_SECONDS
FROM [email protected] LEFT JOIN KS_DRIFT.SYS_DATE_KS AA ON TO_DATE(TRUNC(LAST_UPD),'YYYY-MM-DD') = AA.THIS_DATE
WHERE TIDSPUNKT > (SYSDATE - 427)
Ie add my own function (CALCULATE_CALLBACK_DURATION) then the result of my Java application is = 0. Not null not NaN just 0.
For example if I use the following code in my Java application:
public ArrayList<CallQueue> getCallbacks(String startDate, String endDate,
char c, ArrayList<CallQueue> data) {
DateTime end = new DateTime(endDate);
// this method is currently used for testing purposes
String sql = "SELECT SOLVED_SECONDS FROM KS_DRIFT.NYK_SIEBEL_CALLBACK_AGENT_H_V ";
System.out.println(sql);
ResultSet rs = getTable(sql);
try {
while (rs.next()) {
System.out.println(rs.getInt("SOLVED_SECONDS"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
private ResultSet getTable(String sql){
try {
return Hent_tabel(sql);
} catch (SQLException e) {e.printStackTrace();}
return null;
}
public ResultSet Hent_tabel(String Execute) throws SQLException {
return db.executeQuery(Execute);
}
in the above example the application will print out "0" for each of the rows in the table. However if I look in the table through my DBM the correct number is displayed in the column SOLVED_SECONDS
I feel like I've tried everything and I simply cannot seem to find the problem. if you need additional information please let me know!
Note - in the above example I am able to get any other column in the table with the correct result expect from SOLVED_SECONDS
UPDATE
If I use the Resultset.wasNull(); I get an exception saying no data was read.
Here is a screenshot of the SOLVED_SECONDS in my DBM

And here is the output from Java:

Note that the following output is just a small glimpse the 0's continue for each of the rows in the database.
UPDATE the created view:
The following is the full definition on the view:
Create View KS_DRIFT.NYK_SIEBEL_CALLBACK_AGENT_H_V (CDN, DN_GRUPPE, INITIALS, AGENTGROUP, STATUS, CREATED, LAST_UPD, SOLVED_SECONDS)
As
SELECT
CDN, DN_GRUPPE, AFSLUTTET_AF AS INITIALS,
AGENTGRUPPE AS AGENTGROUP, STATUS, CREATED, LAST_UPD ,
CASE WHEN CALCULATE_CALLBACK_DURATION(CREATED,LAST_UPD) is NULL
THEN CALCULATE_CALLBACK_DURATION(AA.THIS_DATE_OPENING, LAST_UPD)
ELSE CALCULATE_CALLBACK_DURATION(CREATED, LAST_UPD)
END AS SOLVED_SECONDS
FROM
[email protected]
LEFT JOIN
KS_DRIFT.SYS_DATE_KS AA ON TO_DATE(TRUNC(LAST_UPD),'YYYY-MM-DD') = AA.THIS_DATE
WHERE
TIDSPUNKT > (SYSDATE - 427)
.nextwithout parentheses,Resultsetwith lower-cases..., missing closing parenthesis on theprintln()call). Please post the code that you have successfully executed, which is giving you the unwanted zeroes