public static void exec_sql(RfcServerContext context, IRfcFunction function) { getRedshift(); char bNonQuery = function.GetChar("IV_NONQUERY"); string sSQL = function.GetString("IV_SQL"); if (bNonQuery == 'X') { int rows = rsh.executeNonQuery(sSQL); function.SetValue("EV_STATUSCODE", rows.ToString()); } else { DataTable tab = rsh.executeQuery(sSQL); function.SetValue("EV_STATUSCODE", tab.Rows.Count.ToString()); IRfcTable tMetadata = function.GetTable("ET_METADATA"); get_tableMetadata(rsh.getLastSchema(), ref tMetadata); function.SetValue("EV_DATA", convertData(tab)); } if (rshparameters["SERVER"] == "0") { rsh.Dispose(); rsh = null; } }
private static void getRedshift() { if (rsh == null) { rsh = new redshift(rshparameters["SERVER"], rshparameters["PORT"], rshparameters["DB"], rshparameters["USER"], rshparameters["PASSWORD"]); } }