issues with getvavlues and bigint types

This commit is contained in:
Paul Trowbridge 2018-09-10 17:45:26 -04:00
parent b6ee7b651e
commit d889878e37

View File

@ -32,6 +32,7 @@ namespace test
msg = msg + nl + "-t trim text"; msg = msg + nl + "-t trim text";
msg = msg + nl + "--help info"; msg = msg + nl + "--help info";
//---------------------------------------parse args into variables------------------------------------------------- //---------------------------------------parse args into variables-------------------------------------------------
for (int i = 0; i < args.Length; i = i +1 ){ for (int i = 0; i < args.Length; i = i +1 ){
@ -121,6 +122,7 @@ namespace test
//setup getv object array dimensioned to number of columns for scenario //setup getv object array dimensioned to number of columns for scenario
//getv hold an array of datareader row //getv hold an array of datareader row
var getv = new object[ibmdr.FieldCount]; var getv = new object[ibmdr.FieldCount];
int cols = ibmdr.FieldCount;
//dtn holds list of data types per column //dtn holds list of data types per column
var dtn = new string[ibmdr.FieldCount]; var dtn = new string[ibmdr.FieldCount];
while (ibmdr.Read()) { while (ibmdr.Read()) {
@ -129,46 +131,59 @@ namespace test
nr = ""; nr = "";
//populate all the data type names into a string array instead of calling against ibmdr in every iteration //populate all the data type names into a string array instead of calling against ibmdr in every iteration
if (t == 1 ) { if (t == 1 ) {
for (int i = 0; i < ibmdr.GetValues(getv); i++){ for (int i = 0; i < cols; i++){
dtn[i] = ibmdr.GetDataTypeName(i); dtn[i] = ibmdr.GetDataTypeName(i);
} }
} }
for ( int i = 0 ; i < ibmdr.GetValues(getv);i++) { for (int i = 0 ; i < cols;i++) {
if (getv[i] != null) { //Console.Write(nl);
//Console.Write(DBNull.Value.Equals(ibmdr.GetValue(i)).ToString());
//Console.Write(ibmdr.GetValue(i).ToString());
Boolean dnull = false;
if (dtn[i] == "BIGINT") {
dnull = DBNull.Value.Equals(ibmdr.GetInt64(i));
}
else {
dnull = DBNull.Value.Equals(ibmdr.GetValue(i));
}
if (! dnull) {
switch (dtn[i]){ switch (dtn[i]){
case "VARCHAR": case "VARCHAR":
if (trim) { if (trim) {
nc = "'" + getv[i].ToString().Replace("'","''").TrimEnd() + "'"; nc = "'" + ibmdr.GetValue(i).ToString().Replace("'","''").TrimEnd() + "'";
} }
else { else {
nc = "'" + getv[i].ToString().Replace("'","''") + "'"; nc = "'" + ibmdr.GetValue(i).ToString().Replace("'","''") + "'";
} }
break; break;
case "CHAR": case "CHAR":
if (trim) { if (trim) {
nc = "'" + getv[i].ToString().Replace("'","''").TrimEnd() + "'"; nc = "'" + ibmdr.GetValue(i).ToString().Replace("'","''").TrimEnd() + "'";
} }
else { else {
nc = "'" + getv[i].ToString().Replace("'","''") + "'"; nc = "'" + ibmdr.GetValue(i).ToString().Replace("'","''") + "'";
} }
break; break;
case "DATE": case "DATE":
if (getv[i].ToString() == "1/1/0001 12:00:00 AM" || getv[i].ToString() == "") { if (ibmdr.GetValue(i).ToString() == "1/1/0001 12:00:00 AM" || ibmdr.GetValue(i).ToString() == "") {
nc = "NULL"; nc = "NULL";
} }
else { else {
nc = "'" + getv[i].ToString() + "'"; nc = "'" + ibmdr.GetValue(i).ToString() + "'";
} }
break; break;
case "TIME": case "TIME":
nc = "'" + getv[i].ToString() + "'"; nc = "'" + ibmdr.GetValue(i).ToString() + "'";
break; break;
case "TIMESTAMP": case "TIMESTAMP":
nc = "'" + getv[i].ToString() + "'"; nc = "'" + ibmdr.GetValue(i).ToString() + "'";
break;
case "BIGINT":
nc = ibmdr.GetInt64(i).ToString();
break; break;
default: default:
if (getv[i].ToString() != "") { if (ibmdr.GetValue(i).ToString() != "") {
nc = getv[i].ToString(); nc = ibmdr.GetValue(i).ToString();
} }
else { else {
nc = "NULL"; nc = "NULL";