static private void GetProposalFile(Record rec)
{
string connectionString = GetConnectionString();
using (OracleConnection connection = new OracleConnection())
{
connection.ConnectionString = connectionString;
Console.WriteLine("State: {0}", connection.State);
Console.WriteLine("ConnectionString: {0}",
connection.ConnectionString);
connection.Open();
OracleCommand command = new OracleCommand();
string sql = "select f.txt_file, t.* from transactions t, trans_files f" +
" where t.record_id = :pOID" +
" and sequence_no = (select Max(tt.sequence_no) from transactions tt " +
" where tt.record_id = :pOID2 and tt.TRANS_STAT_CD = 'PRICED' and tt.TRANS_TYPE_CD = 'P')";
command.CommandText = sql;
command.Parameters.Clear();
command.Parameters.Add(new OracleParameter(":pOID", OracleType.VarChar));
command.Parameters[":pOID"].Value = rec.RecordID;
command.Parameters.Add(new OracleParameter(":pOID2", OracleType.VarChar));
command.Parameters[":pOID2"].Value = rec.RecordID;
Console.WriteLine("SQLCommand: " + command.CommandText);
command.Connection = connection;
OracleDataReader reader = command.ExecuteReader();
reader.Read();
if (reader != null)
{
OracleLob clob = reader.GetOracleLob(0);
long filesize = clob.Length;
StreamWriter file = new StreamWriter("C:\\Documents and Settings\\user\\Desktop\\Temp\\RecordExtract\\"
+ rec.RecordID + "-" + rec.PropOrdInd + rec.PropTypCd + "-" + rec.LineItemCnt + ".txt",false);
file.WriteLine(clob.Value);
file.Close();
Console.WriteLine(clob.Value);
clob.Flush();
clob.Position = 0;
}
command.Dispose();
reader.Close();
reader.Dispose();
connection.Close();
}
} |