push null test into each type

This commit is contained in:
Paul Trowbridge 2022-10-25 13:24:15 -04:00
parent e60a92cfdc
commit cf5abeddbe
1 changed files with 64 additions and 47 deletions

View File

@ -199,54 +199,71 @@ public class jrunner {
t++; t++;
nr = ""; nr = "";
for (int i = 1; i <= cols; i++){ for (int i = 1; i <= cols; i++){
nc = rs.getString(i);
if (nc == null) {
nc = "NULL";
}
else {
if (rs.wasNull()) {
nc = "NULL";
} else {
switch (dtn[i]){ switch (dtn[i]){
case "VARCHAR": case "VARCHAR":
nc = rs.getString(i).replace("'","''"); nc = rs.getString(i).replace("'","''");
if (rs.wasNull() || nc == null) {
nc = "NULL";
break;
}
if (trim) { nc = nc.trim();} if (trim) { nc = nc.trim();}
nc = "'" + nc + "'"; nc = "'" + nc + "'";
break; break;
case "CLOB": case "CLOB":
nc = rs.getString(i).replace("'","''"); nc = rs.getString(i).replace("'","''");
if (rs.wasNull() || nc == null) {
nc = "NULL";
break;
}
if (trim) { nc = nc.trim();} if (trim) { nc = nc.trim();}
nc = "'" + nc + "'"; nc = "'" + nc + "'";
break; break;
case "CHAR": case "CHAR":
nc = rs.getString(i).replace("'","''"); nc = rs.getString(i).replace("'","''");
if (rs.wasNull() || nc == null) {
nc = "NULL";
break;
}
if (trim) { nc = nc.trim();} if (trim) { nc = nc.trim();}
nc = "'" + nc + "'"; nc = "'" + nc + "'";
break; break;
case "DATE": case "DATE":
nc = "'" + rs.getString(i) + "'"; nc = "'" + rs.getString(i) + "'";
if (rs.wasNull() || nc == null) {
nc = "NULL";
break;
}
if (nc == "'1/1/0001 12:00:00 AM'") { if (nc == "'1/1/0001 12:00:00 AM'") {
nc = "NULL"; nc = "NULL";
} }
break; break;
case "TIME": case "TIME":
nc = "'" + rs.getString(i).replace("'","''") + "'"; nc = "'" + rs.getString(i).replace("'","''") + "'";
if (rs.wasNull() || nc == null) {
nc = "NULL";
break;
}
break; break;
case "TIMESTAMP": case "TIMESTAMP":
nc = "'" + rs.getString(i).replace("'","''") + "'"; nc = "'" + rs.getString(i).replace("'","''") + "'";
if (rs.wasNull() || nc == null) {
nc = "NULL";
break;
}
break; break;
case "BIGINT": case "BIGINT":
nc = rs.getString(i); nc = rs.getString(i);
default: if (rs.wasNull() || nc == null) {
if (rs.getString(i) != "") {
nc = rs.getString(i);
}
else {
nc = "NULL"; nc = "NULL";
}
break; break;
} }
default:
nc = rs.getString(i);
if (rs.wasNull() || nc == null) {
nc = "NULL";
break;
} }
break;
} }
if (i != 1){ if (i != 1){
nr = nr + ","; nr = nr + ",";