Friday, October 20, 2006

Misc : 100 posts


Finally hit the magic number.


Unix : Finding files that start with a .

The classic "ls -l" doesn't show you any files that start with . (which is legal) (e.g. .param) and which are effectively hidden.

You need "ls -al" to ferret out these elusive beasts.


SQL : Comparing VSS stored procedures with the DB

This is a right royal pain. You have to extract every .pkg and .pkb manually e.g. if using SQL Navigator you right click, Extract DDL and save.

But how do you ensure that VSS is up-to-date?

An easy way is to right click on the heading e.g. right click on Package Bodies and then Extract DDL from here. What you are doing is creating one DDL file that contains ALL the package stored procedures.

In VSS, however, each package is stored individually. To combine them, DOS comes to the rescue! Use the copy construct "+".

e.g. copy a + b + c d.

This concatenates a, b and c and puts them in a file called d.

Now you can compare the combined DDL extract with the concatenated file from VSS.

But wait, there's more!

Part of the DDL extract puts the date on the extract and the tnsname that you use to access the DB. Different developers may have different tns names. So you need to remove these lines. This can be done very simply by writing a program to parse the file and create a new one without these lines.

e.g. in C#, something like:

(where the command line is something like 'Program 'input file' 'filtered file'')

static void Main(string[] args)

string readBuffer = "";
int gIndex = 0;
int fIndex = 0;

if (args.Length != 2)

Console.WriteLine ("\nFormat is Prog 'input' 'output'");
System.Environment.Exit (0);



FileStream readStream = new FileStream (args[0], FileMode.Open);
StreamReader fileRead = new StreamReader (readStream);
FileStream writeStream = new FileStream (args[1], FileMode.Create);
StreamWriter fileWrite = new StreamWriter(writeStream);

while (fileRead.Peek () >= 0)

readBuffer = fileRead.ReadLine();

gIndex = readBuffer.IndexOf ("-- Generated");

if (gIndex == -1)

string tempReadBuffer = readBuffer.ToLower();
fIndex = tempReadBuffer.IndexOf ("-- from 'a specific DB string'");

if (fIndex == -1)
fileWrite.WriteLine (readBuffer);



fileRead.Close ();
fileWrite.Flush ();
fileWrite.Close ();


catch (Exception e)

Console.WriteLine("Error : {0}", e.ToString());



So the batch file would be:

copy concatenate statement
run filter on concatenated file
run filter on saved DDL file
compare the two filtered files

You could use something like Examdiff which is free to do the compare in which case the batch file line would be:

start ExamDiff.exe File1 File2


Tuesday, October 17, 2006

Visual Studio : Errors in the output

Quite often when you are doing a build of a large project, the build will fail when some VS utility returns an error. The problem is that you can't see why it fails.

A useful technique is to use the VS command prompt (Start - Programs - VS 2005 - VS 2005 Tools) and cut and paste the command line that failed from the VS output window.

Then execute it - you'll see all the errors.

The other option is to select Tools - Options - Projects and Solutions - Build and Run and change the build output verbosity to "Detailed" or "Diagnostic". Just change it back afterwards or you'll be swamped!