1

I have a table in Oracle with lots of data. In the structure of:

code_value    date_value     value
1             20/07/2017      10.5
1             19/07/2017      11.6
2             20/07/2017      1000.22
2             18/07/2017      1700.44

I have another table that defines a test for this data: Whose structure is as follows:

code_value      check_rule      check_period    connection_rule
1                16%            w               or
1                30%            m               or
1                50%            y               or
2                130%           w               and
2                110%           6m              and

*p.s. "check_period": w - for week, m - for month, y - for year.
** p.s. I'm still debating if split this column into two columns: one for the amount of time and one for the time type (ex: 6, m).

I would like to take the test table and run it on the table with the data, on C#.
but I don't know how to start to do it:
How do I take a value from a table and use it to calculate? for example:
if I will take the first line, with 16% check_rule, and I will do:
var a = check_rule[0];
How to check whether the increase was 16% per week?
In the same way how to use OR on "connection_rule"?

I'm really hope that my question clear enough.

Thank U!

1 Answer 1

1
OracleConnection conn = new OracleConnection("Your Connection string");
conn.Open();
DataSet dataSet = new DataSet();
OracleCommand cmd = new OracleCommand(
    "SELECT * FROM TABLE1 t inner join TABLE2 t1 on t.code_value = t1.code_value"
);
cmd.CommandType = CommandType.Text;
cmd.Connection = conn;

using (OracleDataAdapter dataAdapter = new OracleDataAdapter())
{
  dataAdapter.SelectCommand = cmd;
  dataAdapter.Fill(dataSet);
}

DataTable dt = ds.Tables[0];
//loop through table's rows/columns
var myVal = ParseToDouble(dt.Rows["value"].ToString());
var checkRule = ParseToDouble(dt.Rows["check_rule"].ToString());

if(myVal < checkRule)
   doSomething();


public double ParseToDouble(string s)
{
    return decimal.Parse( s.TrimEnd('%') ) / 100M;
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thank U, But, I know how to connect and how to write code. but I dont know how to replace the dt.Rows["check_rule"].toString() to something that I calculate with it. to do "value" from first table >= check_rule.
You mean like var num = decimal.Parse( a.TrimEnd( new char[] { '%', ' ' } ) ) / 100M;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.