I suddenly realized one big disadvantage about having code in the database (stored procedures etc) - Restoring
Restoring a database disrupts the versioning. Code and data are not versioned together. Database structure and code are usually tied together.
Say i have a procedure i want to modify.
- I edit the SP,
- update it in the database
- run it.
I find an error, correct it and want to run it against the original data. What do i do?
Restore is usually the best option if my test-data has a alot of relations. Maybe i even want to run the sproc against a copy of the production database when fixing a bug.
After each restore i need to update the sprocs to the new version. It can get quite tedious after a while and one risk is that you miss to update something if there are many procedures. One solution to this is to always have the code on disk and version controlled and script the updates into the database.
My opinion is rather clear in this case. Don’t have too much program-logic in the database.
June 11th, 2010 | Tags: sprocs, stored procedures, sybase | Category: Programming, Rants, SQL | Leave a comment
I wanted to list files modified the last n days. Here is a filter function i wrote to help me.
1 function FilterLast([int] $nDays)
2 {
3 begin {
4 $DateToCompare = (Get-date).AddDays(-1 * $nDays)
5 }
6
7 process
8 {
9 %{ if ($_.lastwritetime –gt $DateToCompare) { $_ } }
10 }
11 }
So now i can write
ls | filterlast -nDays 4
December 3rd, 2009 | Tags: powersehll, tips | Category: Powershell | Leave a comment
Henrik Kniberg has written some very interesting things on agile version control. He has some links to other interesting sources as well. Go there, read it!
From Perforce I found this writing about High level best practices in SCM.
Is SCM the acronym for:
Both searches on Google seems to to point in the direction that they roughly are equivalent with the “Software Configuration Management” being a little more high level.
November 19th, 2009 | Tags: scm, software, source code management, version control | Category: Programming | Leave a comment
… or where is my wallpaper?
I wanted to edit the imagefile i had as windows desktop background so i wanted to find out the location of it. Excellent material for a powershell lession i thought.
So where are the special folders? Could it be here:
ls ([Environment]::GetFolderPath('MyPictures')
Found help about how to get windows special folders here and here.
What is [environment+Specialfolder]? Looks like it’s an enum.
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
False True SpecialFolder System.Enum
So you can list all enum names like this.
A nice way to list all options for special folders is:
[environment+specialfolder]::GetNames([environment+specialfolder])
Desktop
Programs
Personal
MyDocuments
Favorites
Startup
…etc
Eventually i had to use the windows dialog and found out that the wallpaper was in:
([Environment]::GetFolderPath('ApplicationData') + "\mozilla\firefox\")
But i learned some new powershell.
November 9th, 2009 | Category: Powershell | Leave a comment
Say you want to recurse a diretory tree and show just the directories.
Yo can write
ls C:\ -rec | %{if ($_.PSIsContainer) { $_ }} | %{$_.Fullname}
Add a little filter function
1 function FilterContainer()
2 {
3 process
4 {
5 %{if ($_.PSIsContainer) { $_ }}
6 }
7 }
Which reduces the first line to
ls C:\ -rec | FilterContainer | %{$_.Fullname}
November 2nd, 2009 | Tags: tips | Category: Powershell | Leave a comment
Here are some clever SQL for searching strings via soundex or like, as well as finding gaps in sequences etc.
August 18th, 2009 | Category: SQL | Leave a comment
Im working on a legacy app written in VB6 and want to write .NET-stuff that integrates with it. I feared that i couldnt have both IDEs installed side by side but it seems to work ok (so far…). The ideal is to put the VB6 environment in a virtual machine and keep it there.
The installation order was VB6 and then VS2008.
Luckilly our app communicates via the server through a DLL and it will be a (relatively) simple task to replace that with a COM-class written in C#.
July 30th, 2009 | Category: .NET, VB6 | Leave a comment
Working a lot with SQL at the moment i found a handy tool for formatting SQL-code.
SqlInform automatic SQL code formatter (http://www.sqlinform.com/)
There is an online version but also a free although time-limited JAVA-program to download. The online version handles just 100 lines of code mind you.
Another online formatter without the 100-line limit. http://www.dpriver.com/pp/sqlformat.htm
Some that i havent tried (yet…)
http://www.orafaq.com/utilities/sqlformatter.htm
http://www.dbainfopower.com/dbaip_free_download_execute.php (free registration )
http://www.wangz.net/cgi-bin/pp/gsqlparser/sqlpp/sqlformat.tpl (Pay)
http://www.ubitsoft.com/products/sqlenlight/sqlenlight.php (pay)
July 28th, 2009 | Tags: sqlcode, sqltools, sqlutilities | Category: SQL | Leave a comment
I found some articles about stored procedures and…
I agree with most of the arguments written in them
My pet peeve about SPs is that its not a good programming language for dealing with logic and control flow. Not at all!
http://statestreetgang.net/post/2008/04/My-Statement-on-Stored-Procedures.aspx
http://weblogs.asp.net/fbouma/archive/2003/11/18/38178.aspx
http://home.comcast.net/~eichler2/misc/AntiSP.htm
http://blog.platinumsolutions.com/node/77
June 17th, 2009 | Category: Note to self, Rants, SQL | Comments (1)
Found a regex for getting SQL-code here.
“(/\*[^\*/]*\*/)|(\r\n\s*)|\t|\s{2,}”
June 17th, 2009 | Category: Note to self, Programming, SQL, utilities | Leave a comment