- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I honestly used to have so much respect for all Oracle tools. I really hope this is a 3rd party application developing PL/SQL code.
Admin
why do in one line what you can do in 10?
Admin
This seems a bit overkill on checks to me.
Admin
The real wtf is this post.
Admin
Anyone care to explain the difference between the following 3 items?
add(FIREDATE DATE(, ))add(FIREDATE DATE())
add(FIREDATE DATE)
Is there a difference?
Admin
This is too bad, this has to be generated!!!
(oh wait...) :)
Admin
Sweet, first reply. Nothing else much to say.
Admin
apparently they are having some staffing issues if they decided to add a column to their employee table to keep track of when their employees are fired
Admin
argh... by the time I posted I was no longer first.
Admin
you snooze, you lose -- try something shorter next time .... like 'first!'
Admin
Fucktard
Admin
forget the goggles, this gives me a migraine just looking at it. All those extra lines of code to generate this hunk of junk must take up the extra 5gb needed to install the "Orable" bloatware.
even their light footprint is still 2gb!!! "Oracle is the Devil"
Admin
My guess is that for the DATE type, it should be just "DATE". But for other types, such as VARCHAR2, it should be VARCHAR2(60) where the number is the width of the column. NUMBER requires two parameters, e.g. NUMBER(8,2) is 8 digits wide with 2 digits after the decimal point (IIRC).
It came out as DATE(, ) instead of NUMBER(8, 2) because the type was DATE instead of NUMBER, and the fields where 8 and 2 would have been were empty strings. It doesn't do any harm since the IF statement checks for $dataType == 'NUMBER' and that is false when $dataType is not NUMBER.
Admin
well you mustn'y have worked with oracle very long have you!
Admin
At least oracle software is bug free and free of security vulnerabilities.
Admin
That code is pretty good, but I laughed harder at this:
Admin
I'm not a real PL/SQL guru, so stop me if this a silly question, but...
that branch is never going to execute, right? Unless the length of an empty string somehow manages to be greater than zero.
Not the kind of brain-damagedness that I usually expect from machine-generated code.
Admin
You misspelled "unless the constant strings 'DATE' and 'NUMBER' suddenly become equal."
You also misspelled "Unless the length of NULL somehow manages to be greater than zero.", because orrible conflates NULL and ''. See the IHOC forums for details.
Admin
Well, I guess if someone is being paid per line of code developed this makes sense......
Admin
I've got it. The bot that generated this code is being paid by the line.
Admin
It looks silly, but the code was probably in the form of a template, and the generator just used replaceable variables. This way, the generator code doesn't have to do all of those checks (is it a NUMBER, INTEGER, etc.), since the generated code will do them.
Admin
That is why Oracle rules and is so expensive. With an open source solution (mysql, PostgreSQL) you'd only get one line!
-- They didn't know they were robots....
Admin
Remember, there is no "reusability", "maintainability", "readability" or even "understandability" criteria for generated code. The only criteria for generated code is: Does it perform its intended task correctly? This appears to do that, even though it is really, really ugly.
It does seem to me that if you know enough to substitute 'DATE' into your template, you should know enough to only choose the part of the template that is needed.
But then again, Orable paid good money for Peoplesoft and JDEdwards - and what quality software that is!
Admin
Fixed:
Admin
Speaking of generated code, has anyone else here ever used Microsoft Excel to generate code?
I do it occasionally, when I'll have a table of data that needs to be hard-coded into an array or something. Just insert columns containing the needed spaces and punctuation, then fill down for all the data. Then just copy/paste the spreadsheet into notepad, s/\t//g, and copy/paste that right into your code. I've never seen anyone else do this, but I figure there must be others that have done this, since it makes a few specific tasks much faster and less error prone.
Admin
Great! Now we're measuring ROI by LOC.
Admin
To expand upon what I said earlier, the template probably looked something like this (just a guess):
Admin
If you think this is bad, you should see what piles of steaming code come out of SQL Server's Enterprise Manager for the very same task. And yes, SQL Server has the ability to add a column in one line. Just no one ever told Enterprise Mangler. The best part of the SQL Server generated code is it includes a drop table statement WITH NO ERROR CHECKING. Have an error? Too bad, I am dropping your one copy of the table, anyway.
Admin
I've written a few code generators that generated some ugly code, so that was my initial reaction as well... All code generators produce WTFs. However, assuming NUMBER and INTEGER are constants in the template, I don't understand the logic that would ultimately produce this:
That's enough for me to confirm it's place on this board.
Admin
Did anyone else have trouble with the pun in the title? It took me a bit; I thought Alex had misspelled Oracle. I almost posted as such, until I finally got the joke.
Admin
Admin
Paul is right ... noWTF here. Move along...
Maybe tomorrow.
A whole lot of ugly SQL gets generated by applications, and SQL people often forget that because it's interpreted code, generated on the fly, things that look like constants might not be. The reason this is ugly is that it's a simple way to make the syntax correct for a variety of column types. A person would not do that, but it's probably because a person would not need to construct code that could handle EVERY datatype, only the one they intend to use.
Admin
Yes. I can't think of any specific code examples, but I remember the time I did it when I was creating some data for the first time. I had a bunch of chart names that needed to be entered into a table and it was much faster to type chartname_1, chartname_2, and then fill down to 40 or so and import than any other sort of copy/paste/backspace/type number method or programming any sort of quick and dirty method for it.
Admin
Remember some days ago when I said SQL is a good query language but an awful programming language?
The real WTF here isn't the logic, it's that the logic is being done in SQL. If PL/SQL had just put those rules in its code, the generated SQL would be a single line.
I've used PL/SQL some. I'm not enough of a database expert to comment on its database capabilities, but I am a UI expert and I know a hideous user interface when I see one. PL/SQL's user interface is hideous.
I'm not surprised they have other problems. The app feels like it's been dragged into this century kicking and screaming.
Admin
I'm no DB guru, so correct me if i'm wrong but isn't length('')=0 like saying 3==3 ?
Admin
If all I need to do is add a column to a table, I'll simply right the one line alter table statement myself instead of having to use a tool to do it. Why bother with a tool SQLDeveloper or doing something in enterprise manager if it is not necessary?
Admin
Admin
Ahh, you have apparently not had to deal with the Disney Automaton Ride Refugees that I have to work with here. I swear, if I close my eyes, I can here them all singing "It's a small world".
Admin
If the template designer had just put all the replaceable parameters in local variables, and used local variables throughout the script, it probably wouldn't have been posted here. Comparing the local var (although hard-coded) to a literal looks a lot better and is easier to understand the purpose behind than comparing two literals.
The whole thing seems very enterprisey. They could've even had file describing forms for various functions, which is then read to display this "Add Column" function, and the data from is then plugged into some "Add Column" template. The system wouldn't even have to know what the forms and templates are for. It pushes any maintenance on the code to a higher, more abstracted level that keeps people from mucking about in the system.
Admin
I think that the main WTF here is that the tool tried throwing the datatype check into the SQL code instead of putting it in the generation tool code.
Admin
Doesn't work, since you cannot have empty branches in PL/SQL (but you can use a null statement to fill it) and if requires a then.
Here is what it's meant to be:
Admin
Screenshots here...
[image]
[image]
Admin
I can't beleive no one has made this joke yet:
It's missing a bit. There should be an
update "SCOTT"."EMP" set FIREDATE = sysdate()
Admin
PL/SQL doesn't have a user interface. There is Orace Forms, a RAD tool that uses PL/SQL as language. Maybe that's what you're thinking of.
Admin
No, since in Oracle lenght('') is null. A good chance to write endless-loops in PL/SQL..
Admin
My mistake. What I used was PL/SQL Developer. I had come to know it as just "PL/SQL." Guess I can take away a lesson about using imprecise terminology.
Admin
Ouch. PL/SQL developer is XXXXXXXXXX. TOAD is much better, though it's expensive. The new tool, SQLDeveloper, seems like a good tool for PL/SQL development to me (despite today's WTF ;-).
My favourite editor for PL/SQL is Slickedit.
Admin
Well... that would still not explain the thing that bullseye homed in on:
If the first condition has already established that the value of %DATATYPE% is 'number', then checking the length of %DATATYPE% must be totally redundant. Unless the template itself is also generated from another template - an even scarier prospect.
Admin
Hans Liss & bullseye: Good point -- that does seem pretty dumb. I noticed it when I was making the template post, but I didn't realize that's what you were talking about. A template template -- now that's enterprise.
Admin
Yes, but is there a template template factory? A template template factory factory?