Sunday, 11 August 2013

I like to remove the empty lines from my query results?

I like to remove the empty lines from my query results?

I like to remove the empty lines from my query results and using below
code, where I am doing wrong? I have 2 connections that getting the result
from different users. I used get.ddl to get procedure definitions and
trying to compare them if they are same or not.Belows are my 2 procedures
ddl result and they are same, but because of the empty lines results shows
not same.
First query result:
CREATE OR REPLACE PROCEDURE "HELL_"
as
begin
dbms_output.put_line('Hello!');
end;
second query result(Which has empty lines)
CREATE OR REPLACE PROCEDURE "HELL_"
as
begin
dbms_output.put_line('Hello!');
end;
my Code
string result1 = "";
string result2 = "";
using (OracleConnection conn1 = new OracleConnection(oradb1))
{
conn1.Open();
using (OracleCommand crtCommand = new
OracleCommand("select
REGEXP_REPLACE(dbms_metadata.get_ddl('PROCEDURE','HELL_'),('user1...'),'',
1, 0, 'i') from dual", conn1))
{
result1 = crtCommand.ExecuteScalar().ToString();
}
}
using (OracleConnection conn2 = new OracleConnection(oradb2))
{
conn2.Open();
using (OracleCommand crtCommand = new
OracleCommand("select
REGEXP_REPLACE(dbms_metadata.get_ddl('PROCEDURE','HELL_'),('user2...'),'',
1, 0, 'i') from dual", conn2))
{
result2 = crtCommand.ExecuteScalar().ToString();
}
}
var lines1 = result1.Split(new[] { Environment.NewLine },
StringSplitOptions.RemoveEmptyEntries).Where(l =>
l.Trim().Length > 0).Select(l => l.Trim());
var lines2 = result2.Split(new[] { Environment.NewLine },
StringSplitOptions.RemoveEmptyEntries).Where(l =>
l.Trim().Length > 0).Select(l => l.Trim());
if (lines1.SequenceEqual(lines2))
{
MessageBox.Show("same");
}
else
{
MessageBox.Show("not same");
}

No comments:

Post a Comment