I never really learned how to write oracle's SQL and pl/SQL statements. I always worked with MySQL and my first contact with oracle was, well gosh, almost exactly one year ago. That was the time when the company I was working for a couple of years, suddenly realized that I in can actually write code (let's not go there...), and they gave me my first project. Which was something written in JSP (that I have never worked with) and oracle (also never worked with). There really wasn't any time for me to read a book or something like that; I just had to get started right away. Well the JSP part was not a problem, I knewed how to write C# and program web pages in PHP, so switching to Java wasn't that difficult (but what a mess those pages I had to rewrite ware...).
The problem was with oracle's SQL. I thought "well, it can't be *that* different from MySQL" so I just started to edit some existing pl/SQL procedures and some simple SQLs. And then every once and a while I came to a thing that I just couldn't figure out (like how to limit results to one row; which is very stupidly done in oracle as far as I am concerned), I had to bug the local oracle guru or study books.
And this is a very bad way to learn something new (don't do this). But I really had no other choice. There wasn't enough time during work time, and I have better (paid) things to do in the afternoon.
Ok to get to the point of this writing (not that the above should be ignored); today I discovered that when you are doing a 'order by' with more columns you have to specify the 'asc/desc' for every column.
So if you do something like this:
So if you are faced with a new technology that you don't know anything about, try to force your boss to give you time to study at least the basics, otherwise you will be burning your and companies time, which could be put to better use.
The problem was with oracle's SQL. I thought "well, it can't be *that* different from MySQL" so I just started to edit some existing pl/SQL procedures and some simple SQLs. And then every once and a while I came to a thing that I just couldn't figure out (like how to limit results to one row; which is very stupidly done in oracle as far as I am concerned), I had to bug the local oracle guru or study books.
And this is a very bad way to learn something new (don't do this). But I really had no other choice. There wasn't enough time during work time, and I have better (paid) things to do in the afternoon.
Ok to get to the point of this writing (not that the above should be ignored); today I discovered that when you are doing a 'order by' with more columns you have to specify the 'asc/desc' for every column.
So if you do something like this:
order byonly column1 will be sorted in descending order. You have to write the SQL like this:
column1, column2 desc
order byJust something you can not possibly know if you didn't read any books. Especially if you came from MySQL where the first SQL above would work like I assumed it would.
column1 desc, column2 desc
So if you are faced with a new technology that you don't know anything about, try to force your boss to give you time to study at least the basics, otherwise you will be burning your and companies time, which could be put to better use.
Avtor: Anonymous, objavljeno na portalu SloDug.si (Arhiv)