2005/11/27

Transaction isolation levels in Oracle Database

There's an interesting article about transaction isolation levels in the last issue (November/December 2005) of Oracle Magazine - On Transaction Isolation Levels by Tom Kyte.

Being a SQL Server guy who has to use NOLOCK all the time, I was surprised to learn that there is no READ UNCOMITTED isolation level in Oracle Database. And here's the explanation how it is solved:
When the query I'm executing gets to the block containing the locked row (row 342,023) at the bottom of the table, it will notice that the data in it has changed since execution began. To provide a consistent, or correct, answer, Oracle Database will create a copy of the block containing this row as it existed when the query began. That is, it will read a value of $100, which is the value that existed when the query began. Effectively, Oracle Database takes a detour around the modified data—it reads around it, reconstructing it from the undo (also known as a rollback) segment. A consistent and correct answer comes back without waiting for the transaction to commit.
Nice.

2005/11/23

Upgrading Ubuntu 5.04 to 5.10 (in, increasingly inaccurately named, 3 easy steps)

All you have to do to upgrade Ubuntu 5.04 (Hoary Hedgehog) to 5.10 (Breezy Badger) is:
  1. Start Synaptic Package Manager.
  2. Go to Settings / Repositories.
  3. Change Distribution from hoary to breezy for every Ubuntu repository (example).
  4. Close the Repositories window; the package information will be automatically reloaded.
  5. Press Mark All Upgrades button and choose Smart Update.
That's all - Synaptic Package Manager will download all the needed packages and install them.

2005/11/01

VS 2005 Beta 2 - cannot create a new project or open an existing one

I have been using Visual Studio 2005 Beta 2005 for a few weeks and one day, completely out of the blue it failed to open my project. I tried to open another one - the same result. I also couldn't create a new project.

Unfortunately, I didn't jot down the error message, but I remember it mentioned Microsoft.Common.targets file.

I checked this file on my machine and it turned out that it was empty. I did some googling to make sure that it is not normal and then reinstalled .NET Framework 2.0 (use repair option) - it helped!

2005/10/17

Ubuntu - smooth fonts (continued)

I wrote this yesterday.

And today I've removed Arial font from my system (you can type fonts:/// in Nautilus and delete appropriate files) and, in my opinion, Google and Gmail look now even better than yesterday, because Firefox uses sans-serif instead of Arial.

2005/10/16

Ubuntu - smooth fonts

My OS is Ubuntu and the browser of my choice is Firefox. Some WWW developers seem to be unaware of the fact that not everyone in the world runs Windows and specify only fonts like Verdana, Tahoma, Helvetica or Arial in the CSS files. On my machine such webpages (example) were rendered with a font that looks like Times New Roman and looked really awful.

To solve this problem I installed msttcorefonts package. This solved one problem... And created another one. Google and Gmail started to look worse than they did before.

After some searching I found this thread and enabled autohinting in /etc/fonts/local.conf file. Both Google and Gmail started to look good again. And what's more all fonts on the system seem smoother and clearer.

Autohinting disabled
Autohinting enabled

2005/10/15

I made amaroK show ID3v2 tags! Finally

I have been using amaroK during the last few months and I think it is an excellent MP3 player (on the other hand, I like foobar2000, too). However, throughout all this time I have struggled with one problem - amaroK kept trimming long song titles, band names, etc (for example, instead of Anyone Can Play Radiohead: A Tribute To Radiohead it showed only Anyone Can Play Radiohead: A T).

Today I have found this and the problem is gone. I've pasted an appropriate piece of amaroK's FAQ below:

amaroK is not using the tags I know are in my files!

If Konqueror or other apps are displaying different Title, Artist, Album or Genre information than amaroK is picking up when it creates your collection, it may be reading the older ID3v1 format tags rather than the newer ID3v2 tags. This can be due to your Encodings setting:
  • Go to Settings, Configure amaroK, and then find the Encodings section of the Settings panel. Unclick all checkboxes to "Do not decode the following as latin1".
  • Rescan your collection to pick up the ID3v2 tags.

2005/10/05

Reflections on installing MSDE

So you've been working with SQL Server for almost two years now?
And you've installed SQL Server a few dozens of times?
And you've passed 70-728 with more than 900 points?

Believe or not, but you still may encounter some problems while installing MSDE. Firstly, there is no wizard; you need to execute setup.exe with appropriate parameters from command-line. And secondly, if you install MSDE using only SAPWD and INSTANCENAME parameters, it will later run in Windows Authentication mode, despite the fact that you have to provide an sa password.

If I had found this article yesterday, it would have saved me a lot of headaches. I didn't, so I had to work it out all by myself. I learned a lot.

2005/09/16

Is this job still executing?

It is easy to use Enterprise Manager to check whether a job is still executing or not.

But I needed to get this information programmatically.

This is a small stored procedure that tells whether a job is running or not.
CREATE PROCEDURE dbo.IsJobRunning
(
  @job_name varchar(255),
  @is_job_running int OUTPUT
)
AS
  BEGIN
    DECLARE @job_id uniqueidentifier 
    
    CREATE TABLE #xp_results 
    (
      job_id uniqueidentifier NOT NULL,
      last_run_date int NOT NULL,
      last_run_time int NOT NULL,
      next_run_date int NOT NULL,
      next_run_time int NOT NULL,
      next_run_schedule_id int NOT NULL,
      requested_to_run int NOT NULL, -- BOOL
      request_source int NOT NULL,
      request_source_id sysname COLLATE database_default NULL,
      running int NOT NULL, -- BOOL
      current_step int NOT NULL,
      current_retry_attempt int NOT NULL,
      job_state int NOT NULL
    )
    
    SELECT @job_id = sj.job_id 
    FROM msdb.dbo.sysjobs sj
    WHERE sj.name = @job_name
    
    INSERT INTO #xp_results
    EXEC master.dbo.xp_sqlagent_enum_jobs 1, ''

    SELECT @is_job_running = running
    FROM #xp_results
    WHERE job_id = @job_id
  END
After a few days of struggling I think this is the best way to do it.

2005/09/15

How to insert multiline text when Form.AcceptButton is set?

I've just re-discovered it - I don't like re-discovering things. I have spent an hour trying to solve this problem and once I've figured out how to do it, I've realized that I had had exactly the same problem about a month ago and I had already worked it out back then.

Anyway, let's describe the problem first:
1. There is a form - myForm.
2. There is a TextBox (or RichTextBox) control on myForm - myText. There is also a Button - myButton - on the same form.
3. The AcceptButton property of myForm is set to myButton.
4. The myText.Multiline is set to true. However, pressing Enter key does not insert a newline, but activates myButton instead.

The solution is simple:
1. In myText.GotFocus (or myText.Enter) event set myForm.AcceptButton to Nothing (VB) or null (C#).
2. In myText.LostFocus (or myText.Leave) event set myForm.AcceptButton back to myButton.

2005/08/14

Why can't I decrypt a string I've just encrypted?

If you are using one of .NET CryptoService providers (like DESCryptoServiceProvider or RijndaelManaged), there's a trap that you can easily fall in (I did).

To encrypt data (a string converted previously into a byte array), you create a CryptoStream that reads bytes from this array, transforms them, and then writes encrypted data to a stream.

Then you can use ToArray() method of the stream to obtain encrypted bytes.

And what do you do next?

You run something like:
  Encoding.Unicode.GetString(cipherBytes)

And you have a problem. The encrypted string is encoded in Unicode. That's fine as long as you want to write it into a file or store in a database, but sometimes you want to be able to enter it using the keyboard.

To solve this problem use:
  Convert.ToBase64String(cipherBytes)

This way the encrypted string will be encoded with ASCII characters only.

If you want to know more, read this article.