12.07.2010Using utPLSQL with multiple schemas

I really like unit testing, and nowadays there is an helping framework for almost every environment and/or programming language. For PL/SQL this is utPLSQL, which consists of a bunch of packages that you need to put on your database and then you should be good to test your could. You should.

I just spent some hours debugging my test code, so I want to share this with you, maybe I can save someone out there some time.

My setting

  • Schema A: utPLSQL package
  • Schema B: package XY (code to test), package UT_XY (test code)

I have two schemas A and B. In schema A utPLSQL is installed, and in B is the code to test. It is recommended to have your code to test and your test code in the same schema.

The following script is used to run the tests:

   for c in (select object_name,owner
               from all_objects
              where object_name like 'UT\_%' escape '\'
                and object_type ='PACKAGE')
       package_in => substr(c.object_name,4),
       prefix_in => 'UT_',
       owner_in => c.owner
     -- in case of a faulty unittest continue with the others.
     when others then
   end loop;

But I kept getting the error:

 Program named "XY" does not exist.

So I thought that somehow the schema A does not “see” the packages in the schema B and created public synonyms. Unfortunately this didn’t help. Then I tried to move the “UT_” package to schema A, which worked, but now I got an error that the code to test and the test code are in different schemas.

There must be something obvious I’m missing!

And there it was: A had not “execute” grant on the packages in B.

  grant execute on b.xy to A;

Now everything just worked fine.

30.05.2010Erroneous copyFrom() method in JCIFS/VFS

At the HSR (University of Applied Science Rapperswil) we are currently developing a software to synchronize files from the central fileserver to the students computers. This should help the students to get the latest slides for their lectures.

The software is based on VFS (Virtual Filesystem) from the Apache Commons project. The file server is a classic Samba server that uses the CIFS protocol, and with the use of VFS we ensured a common access the the filesystem, no matter if it’s the remote filesystem of the file server or the local filesystem on the student’s computers.

At a point we got a very strange error: we could copy files from the remote system, but when we delete the files while the application is running, and try to copy the files again, the copy fails:

FileSystemException "could not copy [source-path] to [target-path]".

We figured out, that the problem were the folders that don’t exist yet. But according the the documentation of the the copyFrom method the parent folder should be created if it does not exist. This is also the case when we do the first-time-copy, which works like a charm.

After serveral tries with refresh() etc. to bring the FileObjects and the actual filesystem to sync, we finally implemented this workaround, maybe somebody else can use it:

protected void copyFile(FileObject targetFile, FileObject sourceFile) {
    try {
        FileObject parentFile = targetFile.getParent();
        log.debug("Parent exists?: " + parentFile.exists());

        if (!parentFile.exists()) {
            log.debug(" => Folder created");
        targetFile.copyFrom(sourceFile),new AllFileSelector());
    } catch (FileSystemException e) {
        log.warn("Could not copy file, FileSystemException: "
                + e.getMessage());

(the above code is a little bit simplified, and the use of an extra FileObject for the parent is not absolutely necessary, but it clarifies the code)

In my opinion the copyFrom implementation of JCFIS (which is the Samba part of VFS) does not work, i.e. this is a bug. But I’m not sure, maybe we overlook an obvious thing on our side. Fact is, the above solution works for us. The JCIFS is part of the VFS sandbox, this means the library is still in development. Maybe I’ll file a bug, if I can clearly reproduce this behavior.

23.12.2009Guardian: How do I know China wrecked the Copenhagen deal? I was in the room


With the deal gutted, the heads of state session concluded with a final battle as the Chinese delegate insisted on removing the 1.5C target so beloved of the small island states and low-lying nations who have most to lose from rising seas. President Nasheed of the Maldives, supported by Brown, fought valiantly to save this crucial number. "How can you ask my country to go extinct?" demanded Nasheed. The Chinese delegate feigned great offence – and the number stayed, but surrounded by language which makes it all but meaningless. The deed was done.

22.12.2009How to make your eye feel like it's closed, when it's actually open


In fact, my left eye felt as if it was closed. I made every effort to open the eye, but it seemed that some unstoppable force was keeping it closed. The only way to make my eye feel as if it was open was to cover it with my hand. I still couldn’t see anything with the eye, but at least I could convince myself it was open.


I think this summarizes everything.

03.12.2009Charles Lewinsky äussert sich in einem Essay über das Minarettverbot, den ewigen Populismus und Roger Köppel


Wir haben den Kampf gegen diesen eidenbenzischen Pseudodenk nie wirklich aufgenommen, weil wir uns nicht vorstellen konnten, dass eine Mehrheit solche logischen Bocksprünge mithüpfen würde.

11.11.2009The Go Programming Language

Today I came across a new programming language called Go, developed by Google

It is meant to be fast, but still garbage collected and type safe. They use pointers, but no pointer arithmetic.

The questions remains: Do we really need another C++-like language?

See Yourself:

09.11.2009Extract .tar.gz to specific directory

I want to extract all files form a “.tar.gz” file to a specific directory (not the current).

When you ask Google you quickly come up with the elegant solution:

$ gzip -cd /some/dir/something.tar.gz | tar -xvf - -C /specific/directory

Somehow my development machine doesn’t accept this, as I keep getting the error:

File -C not present in the archive.
File /specific/directory not present in the archive.

I couldn’t find the answer, but as usual many ways lead to Rome. I’m able to extract the files to the current directory using

$ gzip -cd /some/dir/something.tar.gz | tar -xvf -

Therefore I can simply change the current directory to my specific directory and after the extraction return to the prior directory (I need to unzip the file in a script, therefore I need a generic approach). When we put all that together the following finally works:

$ cd /specific/directory && gzip -cd /some/dir/something.tar.gz | tar -xvf - && cd -

09.11.2009WWFM VI in Zürich

Am nächsten Wochenende (14. November 2009) ist wieder mal ein World-Wide-Flash-Mob (WWFM) der Geocache-Anhänger. WWFM

Dieser Event steht ganz im Zeichen der kalten Jahreszeit und wird mit Wunderkerzen und Räbeliechtli bestritten. Der Clou ist etwas Verwirrung und Verwunderung zu stiften und natürlich sich mal wieder zu treffen.

Solche Event-Caches sind immer eine wunderbare Gelegenheit sich über Caches zu unterhalten, mal Leute zu sehen die man sonst nur liest oder einfach in der Gruppe eine lustige Aktion durchzuführen.

Also alle Cacher da draussen: Kommt auch nach Zürich, oder besucht einen der 150 anderen WWFM Event Caches in eurer Nähe!