petek, 29. september 2006

DB2 Cultural Correct Collation

I think that we all know that DB2 does not support cultural correct collations in it's databases, even if they are created as a UTF-8 database.
I've been pointed to one article that does solve the issue (at least until DB2 implements this in it's engine).

DB2 "Virtual" tables

In DB2 you sometimes need a virtual table. I call table a virtual if you don't know in advance what the structure of it will be and you don't need the virtual table to be persistent.
Let's say that you have a table on you GUI form that has three columns (C1, C2, C3) and the data there are: (1, 2, 3) (4, 5, 6) (7, 8, 9) and you would like to do some SELECT statements over this table:
SELECT * FROM TABLE(VALUES((1, 2, 3), (4, 5, 6), (7, 8, 9))) T(C1, C2, C3)
With T(C1, C2, C3) you say that table T has columns named C1, C2 and C3. This table T acts like any other ordinary table. You can so SUMs, GROUP BYs, .... on it.

I've heard this is DB2 v2 stuff, but I still find it powerful. :)))

petek, 22. september 2006

Mandriva 2007.0 RC2

Yesterday I've tried Mandriva 2007.0 RC2. All I have to say is WOW. :)))
Especially for the XGL/AIXGL stuff. It's working out of the box. couple of months ago I've been trying it on various distributions (SuSe, Ubuntu, ...), but none of them was working good. Some had some painting issues and on some distributions my mouse froze after a while. i was planning on using XGL/AIXGL on my machine, but I had to give the idea up. Until now. :))) I'll see how the final release will be and then I might use it.
Maybe not on my machine at work since it has a SIS graphics card (integrated of course :(((( ) which has terrible performance. My machine at home has a nVidia 6600 GT card so everything should work on it. I llok forward to trying the final release.

petek, 15. september 2006

Strange C++ errors

If you have a code:
std::vector vec;
vec.push_bacnk(3); // push_bacnk is not a member of type vector

and you compile it you get an error:

main.cc: In function ‘int main(int, char**)’:
main.cc:311: error: ‘class std::vector, std::allocator >, std::allocator, std::allocator > > >’ has no member named ‘push_bacnk'


I have to say that this one was easy to track down. :)
What's all about std::shar_trails, std::basic_string, .... ?!?

Power of Java

I've been involved with C++ for about two weeks now and I'm beginning to understand the power of Java that I've always taken for granted. :)
Java and C++ are much the same except that Java's power lies in it's libraries and it's GUI. In Java there is java.util.* that has a lot of helper classes (like Properties for example) that I couldn't find in C++ so I had to write it myself. Another thing is the GUI. If I program in Java there is no question about what GUI I'll be using. Swing it is! There is no such thing in C++. There are tons of different GUIs there. Some are cross-platform and some are not.
I also have to say that I like C++ generics (called templates) more that ones found in Java. Maybe it's just me. :)) there is a lot of strange systax involved in this, but C++ generics are a lot more powerfull.

sobota, 9. september 2006

Learning C++

I've been learning C++ for last couple of days. I must say I briefly met with C++ during my university years (1995 - 2001), but I've always considered myself more of a Java programmer. In fact I've been doing 100% Java for the last 5 years developing server applications.
My newly aquired hobby in genetic algorithms will probably require me to program them in C++. I've tried Java, but I have to make it faster.
Of course I wanted to see how fast parts of the code are in Java and in C++. If you want to see that in Java you just write:
long beginTime = System.currentTimeMillis();
..... code you want to measure
long endTime = System.currentTimeMillis();
System.out.println("Code took " + (endTime - beginTime) + " ms to execute");

this way you get fairly good feeling what parts of your code are slow. Of course you could use Profilers, but usually I don't.
Well.. I tried the same thing in C++. Guess what. You cannot do that. There is no elegant way to do that. You cannot get time in milliseconds/nanoseconds in C++. You have to use a hack (IMHO).
there is a function clock() that returns how many CPU ticks have elapsed. Then your code looks something like:
int startTime = clock() / CLOCKS_PER_SEC;
..... code you want to measure
int endTime = (clock() / CLOCKS_PER_SEC) - startTime;
Ugly if you ask me!!!

If anyome has a better solution, please come forward. :)

petek, 1. september 2006

Jet Lag

Since the day I came back from the US, I feel sleepy and others say I look tired. Wonder why? I think it is the jet lag. But I thought it wears offf after couple of days. I never had a jet lag this powerfull. Hmm...
Finally I installed DB2 V9.1 and it got a feture we'll need a lot, because Slovenia will change it's currency on the 1st of January 2007. We'll have Euros. So no more exchanging Slovenian Tolars when I go to Germany, Austria, .... Woohoo!! It's kinda sad to see the Tolar go (especially because we waited for a long long time to get our own state and currency), but I like the fact I'll have Euros in my pocket. :)
Now. back to DB2. In the latest version you can do something like this:
ALTER TABLE TABLE1 ALTER COLUMN PRICE SET DATA TYPE DECIMAL(18, 6)
So you can change data type on columns of the fly :))
This is what we've been waiting for for almost two years. :)) Sure one can do export, create, import, but this a lot faster and easier.