Home > Oracle > Do while (attention != focused_on_code){ loop }

Do while (attention != focused_on_code){ loop }

August 8, 2006

So, I spent a good portion of today fighting with Oracle data objects trying to figure out why I could NEVER get my stored procedures to run.  Given, I have been fighting fires all day on other issues, so my attention has only been about 50% on my coding…

Plagued constantly with errors (ORA-00942, PLS-00201, ORA-06550, etc), I finally walked away, went outside, soaked up some 105F temps, and came back inside.

.

..

….

…..

DING! Bingo.

… oh.  *sulk* …

Lesson of the day?  Connecting to the CORRECT database makes querying it much easier.  The “declare procedure, can’t find it” errors were truly idiot errors–I had forgotten to set my connection string.  Doh.

On the flip side? See code [more].

BaseDataClass Layer:

protected void Execute()
        {
            try
            {
                OpenOracleConnection();
                Cmd.CommandType = CommandType.StoredProcedure;
                Cmd.CommandText = procName;
                Cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

Data Layer:

public bool updateStaff(string old_name, string new_name)
        {
            try
            {
 
                procName = "SP_UPDATESTAFF";
                Cmd.Parameters.Add(GetParameter("vOLD_ID", Oracle.DataAccess.Client.OracleDbType.NChar, 50, old_name, ParameterDirection.Input));
                Cmd.Parameters.Add(GetParameter("vNEW_ID", Oracle.DataAccess.Client.OracleDbType.NChar, 50, new_name, ParameterDirection.Input));
 
              //  procName = "UPDATE staff SET ad_id = '" + new_name + "' WHERE ad_id = '" + old_name + "'";
 
                connString = connString_KPR;
                Execute();
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                ClearOracleParameters();
                CloseOracleConnection();
            }
        }

Logic Layer:

public bool updateStaff(string old_name, string new_name)
        {
            OracleData.Data data = new OracleData.Data();
            return data.updateStaff(old_name, new_name);
            data = null;
        }

Presentation Layer:

protected void Button1_Click(object sender, EventArgs e)
    {
        OracleBiz.Biz updateStaff = new OracleBiz.Biz();
        try
        {
            if(updateStaff.updateStaff(TextBox1.Text.ToString(), TextBox2.Text.ToString()))
            {
                Label2.Text = "Updated " + TextBox1.Text.ToString() + " to " + TextBox2.Text.ToString() + " successfully.";
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
 
        updateStaff = null;
 
 
 
    }

Categories: Oracle
%d bloggers like this: