add option to trim text
This commit is contained in:
parent
8c8df89cf8
commit
80cddb08bc
21
runner.cs
21
runner.cs
@ -15,6 +15,7 @@ namespace test
|
|||||||
string dcs = ""; //= "Host=ushcc10091;Port=5432;Username=ptrowbridge;Password=qqqx53!026;Database=ubm;ApplicationName=runner";
|
string dcs = ""; //= "Host=ushcc10091;Port=5432;Username=ptrowbridge;Password=qqqx53!026;Database=ubm;ApplicationName=runner";
|
||||||
string sq = ""; //= System.IO.File.ReadAllText(@"C:\Users\ptrowbridge\Documents\runner\osm.sql");
|
string sq = ""; //= System.IO.File.ReadAllText(@"C:\Users\ptrowbridge\Documents\runner\osm.sql");
|
||||||
string dt = ""; //= "rlarp.omsi";
|
string dt = ""; //= "rlarp.omsi";
|
||||||
|
Boolean trim = false;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
int t = 0;
|
int t = 0;
|
||||||
string sql = "";
|
string sql = "";
|
||||||
@ -23,11 +24,12 @@ namespace test
|
|||||||
string nl = Environment.NewLine;
|
string nl = Environment.NewLine;
|
||||||
|
|
||||||
string msg = "Help:";
|
string msg = "Help:";
|
||||||
msg = msg + nl + "version 0.16";
|
msg = msg + nl + "version 0.17";
|
||||||
msg = msg + nl + "-scs source connection string";
|
msg = msg + nl + "-scs source connection string";
|
||||||
msg = msg + nl + "-dcs destination connection string";
|
msg = msg + nl + "-dcs destination connection string";
|
||||||
msg = msg + nl + "-sq path to source query";
|
msg = msg + nl + "-sq path to source query";
|
||||||
msg = msg + nl + "-dt fully qualified name of destination table";
|
msg = msg + nl + "-dt fully qualified name of destination table";
|
||||||
|
msg = msg + nl + "-t trim text";
|
||||||
msg = msg + nl + "--help info";
|
msg = msg + nl + "--help info";
|
||||||
|
|
||||||
//---------------------------------------parse args into variables-------------------------------------------------
|
//---------------------------------------parse args into variables-------------------------------------------------
|
||||||
@ -50,6 +52,9 @@ namespace test
|
|||||||
case "-dt":
|
case "-dt":
|
||||||
dt = "INSERT INTO " + args[i+1] + " VALUES ";
|
dt = "INSERT INTO " + args[i+1] + " VALUES ";
|
||||||
break;
|
break;
|
||||||
|
case "-t":
|
||||||
|
trim = true;
|
||||||
|
break;
|
||||||
case "--help":
|
case "--help":
|
||||||
Console.Write(Environment.NewLine);
|
Console.Write(Environment.NewLine);
|
||||||
Console.Write(msg);
|
Console.Write(msg);
|
||||||
@ -132,10 +137,22 @@ namespace test
|
|||||||
if (getv[i] != null) {
|
if (getv[i] != null) {
|
||||||
switch (dtn[i]){
|
switch (dtn[i]){
|
||||||
case "VARCHAR":
|
case "VARCHAR":
|
||||||
|
if (trim) {
|
||||||
|
nc = "'" + getv[i].ToString().Replace("'","''").Trim() + "'";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nc = "'" + getv[i].ToString().Replace("'","''") + "'";
|
||||||
|
}
|
||||||
nc = "'" + getv[i].ToString().Replace("'","''") + "'";
|
nc = "'" + getv[i].ToString().Replace("'","''") + "'";
|
||||||
break;
|
break;
|
||||||
case "CHAR":
|
case "CHAR":
|
||||||
nc = "'" + getv[i].ToString().Replace("'","''") + "'";
|
if (trim) {
|
||||||
|
nc = "'" + getv[i].ToString().Replace("'","''").Trim() + "'";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
nc = "'" + getv[i].ToString().Replace("'","''") + "'";
|
||||||
|
}
|
||||||
|
nc = "'" + getv[i].ToString().Replace("'","''") + "'";
|
||||||
break;
|
break;
|
||||||
case "DATE":
|
case "DATE":
|
||||||
if (getv[i].ToString() == "1/1/0001 12:00:00 AM" || getv[i].ToString() == "") {
|
if (getv[i].ToString() == "1/1/0001 12:00:00 AM" || getv[i].ToString() == "") {
|
||||||
|
Loading…
Reference in New Issue
Block a user