Monday, January 26, 2009

Sql Server StoredProc rant

As long as it's been, we programmes that write real code, have mostly used C++ to write quality stuff. (I imagine Windows itself is written in c++).

Why can't stored procedures look like c++ functions, and why weren't they designed that way in the first place. C is one of the first code interpreters ever. WTF...

I have been doing SqlServer for years, and you gotta think the dude that designed the storedproc compiler was seriously on drugs. They should have an option to view SqlServer procedures as c type structures, and design them that way as well. I really don't see a problem with fixing that stuff to work more like real programs.

It's cumbersom to write, it's just BS the way that was allowed to happen.

Thursday, September 20, 2007

cool static function

static public void PopulateHiPattern(string sql,ref UltraTree utree,string key)
{
DataView dvResults;
utree.BeginUpdate();
dvResults = new DataView(local.FillDT(sql));
string sortstr = "";
UltraTreeNode utn;
int ColumnCount = dvResults.Table.Columns.Count - 1;
int i1;
foreach(DataColumn dc in dvResults.Table.Columns)
{

sortstr += dc.ColumnName + ",";
}
i1 = 0;
int keyloc = -1;
foreach (DataColumn dc in dvResults.Table.Columns)
{

if (key == dc.ColumnName)
keyloc = i1;
i1++;
}
if (keyloc == -1)
throw new Exception("No keymatched");

sortstr = sortstr.Remove(sortstr.Length - 1);
dvResults.Sort = sortstr;
UltraTreeNode [] utna;
utna = new UltraTreeNode[ColumnCount];
string [] prev;
prev = new string[ColumnCount];
for (int i = 0; i < ColumnCount; i++)
{
prev[i] = "init1234init!@#$";
}

foreach (DataRowView drv in dvResults)

{

for (int i = 0; i < ColumnCount; i++)
{
if (drv[i].ToString() != prev[i])
{
if (i == 0)
{
utn = new UltraTreeNode(drv[i].ToString());
utree.Nodes.Add(utn);
utna[i] = utn;
}

else
{
utn = new UltraTreeNode(drv[i].ToString());
if(i+1 == ColumnCount)
{
utn.Tag = drv[i+1].ToString(); //put key in here.
}
utna[i - 1].Nodes.Add(utn);
utna[i] = utn;
}

}

}
for (int i = 0; i < ColumnCount; i++)
{
prev[i] = drv[i].ToString();
}

}
utree.EndUpdate();

}