- 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've actually used Photoshop to generate code before (and I don't mean with the listener plugin, though I've done that, too). For what it's worth, this was for image processing, so it's not quite as weird as it seems.
Admin
Just for the record, the lengh(whatever)=0 check is never true in PL/SQL. The whole idea with those templates is questionable, and this template is definitely broken.
Admin
I hate Oracle and everything it stands for. If you like Oracle, then I'm sorry, but you have an illness. If you are forced to use Oracle because your management doesn't know better, then I'm also sorry.
tdog
Admin
Give me a break... The only wtf here is this post.
So if one code generation tool is bad, all code generation is bad? Why don't you just say that all programmers are bad? There certainly seems to be an abundance of examples to support that theory, based on the same logic.
This code is bad, because whoever wrote the code generation mixed checks that could have been done at "generation time" and checks that could have been done at runtime. That's actually a very common error. It tells me nothing about how good/bad a programmer whoever wrote the tool is.
Admin
Right on. I have never written anything in PL/SQL; I was just attempting to make a bad joke...
Admin
we have a whole damn hospital of 3000 people running on an enterprise oracle database. remote hosted in another state. accessible via citrix. over two T1 lines. integrated with onsite stand-alone oracle databases (supplied by seperate vendors) via HL7 interfaces. at my last count, we had 8 seperate oracle databases at our hospital. =(
Admin
I would amend that with a second criteria: Does it perform its intended task efficiently?
This example certainly does not meet that.
Admin
This template does not even perform its intended task correctly. It works for DATE, but it breaks e.g. for NUMBER(5);
the
part is obviously wrong in several ways. There is no need to check the lenght of the name of the datatype (in this place there probably should have been the value of the next field) and a length(whatever)=0 check always fails.
Admin
What is this code being generated for? If it's for users to modify and put into their programs/scripts, then the tool should make a bigger effort. If it's meant to be run and thrown away, or regenerated each time it's needed, then there really is nothing to be gained from having the tool generate "pretty" code, or maybe even efficient code. For all you know, the compiler/interpreter that receives the code might even do static analysis that reveals that some branches are unreachable, and not produce code for them. I've myself written a fair amount of code generation code, and if I have to choose between producing "pretty" code that a human might have written, and "ugly" code that has an invariant that simplifies the task, it's always the latter.
Admin
If a database tool lets you add a column to a table (a fairly simple task, I may add), it should do it correctly. This tool doesn't. (see above). If (and only if) this tools also offers you to show the SQL statement for that operation (this tool does, see the screenshots), it should rather make sure it doesn't look like a moron.
Admin
egad!
I feel your pain.
Admin
Are you mixing editors here? I can't imagine Notepad does sed. How do you search on a tab character? Or do you paste one into the dialog box from somewhere else?
A different type of code generator you all might appreciate:
World's 2nd and 3rd Simplest Code Generators
http://secretgeek.net/w2scg.asp
http://secretgeek.net/w3scg.asp
Admin
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.
1,$s/\([0-9]+\) +\([0-9]+\)/ { \1, \2 },/
in your editor? (OK, Maybe. I admit it took a while to come up with that. Not
longer than it takes to start excel, but maybe you always have it running.)
:-)
Admin
Some of that may be due to the fact that in SQL Server (at least in the 2000 version), views behave unpredictably (and usually incorrectly) when you change the underlying table. I do my changes manually (so I can keep each change in SVN), but I make a habit of updating all views, functions, and stored procedures whenever I alter a table.
Admin
PL/SQL is a dialect of Ada, so various Ada tools will work with it. I use Textpad with PL/SQL, Ada, and Oracle syntax files, and I'll probably switch over to Eclipse if they ever get the Oracle plugins to work right.
SqlDeveloper has a much cleaner UI than TOAD or sqlNavigator or PL/SQL developer, so I use it as an object browser when I'd never touch the other 3.
The competing products do at least as silly things as the code fragment (which will work, at least), but they are nowhere near as bad as the bottom feeder CASE tools. Try generating a schema from ERwin or qDesigner sometime...
Admin
I've used ERwin for years and find it indispensible (for SQL Server...I can't speak to Orable schema gen). The only thing that gets me from time to time is when I forget to explicitly specify an index as nonclustered; it defaults to clustered in SQL Server.
What's yer beef with it?
Admin
Admin
The main problem with ERwin for Oracle is that it picks values for the myriad storage values; since v6 Oracle has been moving increasingly towards managing its own storage, so you have to edit the generated DDL to take that stuff out.
ERwin is also years behind Oracle in feature support. As recently as 2 years ago it did not support Oracle partitions.
Admin
Doesn't anyone here feel bad for Scott? I bet they laid him off so they could hire Paula...
Admin
Not so helpful if you have some twisted formula (for sake of argument you want to generate a table for CRC calcs); but I'm sure you could do it in emacs :P - not to say that I haven't found other twisted ways of getting tables I want.
Admin
I am curious what you feel is a valid alternative ;) Though I tend to agree, I might guess that your DB of choice might also be a steaming pile of crap (unless you are talking about Postgres, then, never mind.). But, if you are talking about SQL server, gadzooks! SQL server is teh WORST db there is (yes Alex, worse than MySQL).
Admin
Why doesn't SQL Server have support for regular expressions? what year is it?
Admin
Umm... Not to mention that everything posted was pretty damn garbled (yes, I know I misspelled that one) up, but checking length of number wouldn't be redundant. Of course, checking the length of "number" would :)
IHOC 4 Eva...
Admin
It's 2006. SQL Server got support for Regular Expressions last year. It also got support for everything else the .Net Framework can do -- like real encryption, file IO, event logging, and a billion other things it was lacking.
Admin
Actually, Scott did very well for himself: http://www.orafaq.com/faqora.htm#SCOTT
...but I'm not so sure about Tiger...
Admin
The real WTF here is that Scott gets fired so much he gets a whole column!
Admin
(typos corrected)
The length of a zero-character string is not zero, but instead specially set to this weird version of the "null" concept that SQL has, which in turn fails to check equal to zero? I vote that's the WTF right there.
Admin
I do this all the time. I find that lazy people like myself often come up with many tricks like this. Another of my favorites is column edit mode, why copy and paste something on a bunch of lines when you can type it on 500 lines at once?
Admin
Fo those who do not undestand i give you the template(theoretical) that generated this thing(say if we had it in PHP):
$fullTableName = "SCOTT"."EMP"
$name = FIREDATE
$type = DATE
$size = '' -empty
$precision = '' -empty
begin
if $type = 'NUMBER' and length($size)>0 and length($precision)>0 then
execute immediate 'alter table $fullTableName add($name $type($size, $precision))';
elsif $type = 'INTEGER' or
($type = 'NUMBER' and length($size)>0 and length($precision)=0) or
$type = 'VARCHAR2' then
execute immediate 'alter table $fullTableName add($name $type($size))';
else
execute immediate 'alter table $fullTableName add($name $type)';
end if;
end;
Note that I give $size as an empty string, but the code gives 'DATE', that's probably beacause of substring.
If this was a FIRENUMBER NUMBER(8,2)
$name = FIRENUMBER
$type = 'NUMBER'
$size = '8'
$precision = '2'
You would not have to change a line in the template, and it would still work! GENUS!
Admin
ahhh. thanks for making me laugh this morning. thanks very much!
Admin
Based on the name of the table, I'd guess that "EMP" is a general "employee" table, with name, address, phone #, etc. The real WTF is keeping hiring/firing data in the same table as this other information.
What happens when you re-hire somebody who worked with you in the past?
I'm not surprised that they're having some staffing issues, since they can't seem to hire a competent DBA...
Admin
or just try not being a knobhead
Admin
Wrong, wrong, wrong.
EMP is a table in the "SCOTT" example database that Oracle installs per default. (Think of MS' Northwind)
Adding "FIREDATE" was just a pun, because there is already a column "HIREDATE".
Admin
To be fair, if a 2Gb footprint is a "big thing" to you, you probably don't need Oracle.
Admin
I did that a lot several years ago, typically when I was going to do add a lot of rows in a database (Oracle, at that time, actually) and the INSERTs could easily be created using constant text plus values calculated by Excel. It was probably the easiest way to do those tasks (not very enterprisy though).
Admin
I do that regulary, when I have an excel sheet with data to insert into the database. By generating insert statements, I have a chance to know exactly what will be inserted. (In most cases I do that when I'm not connected to the database, so some fance ODBC connector would not help at all)
Admin
Yeah, thanks for your contribution. twice. It's good to see who's first, and who's not. After all, simply seeing a post at the top isn't enough to tell us it's first, it has to say it too.
Admin
HL7. There's another WTF right there
I as often fondly say, HL7 is a non-standard.
Admin
Is that so? If that is TRUE I would call that a major WTF
Admin
Having the empty string '' equivalent to NULL is something a lot of people have a LOT to say about, but when you think about it, it makes sense... Some sense, anyway. Not that it really FEELS right in the bones, but SOME sense it makes... Patience you have not... Erm... WTF?
Admin
The Oracle redneck (http://dba-oracle.com/oracle_news/2005_5_9_why_i_hate_club.htm), that is?
Admin
I strongly beg to disagree on this. PL/SQL developer can do anything TOAD can do, if not more. People only sweat TOAD because it came first and is synonymous with IDE's. PL/SQL is around $200 - TOAD runs over $500 plus every additional module you need sends that number higher and higher. What exactly do you not like about it?
Anyway enough about which one is better. If you are using an IDE to insert, update, delete data in your database directly (instead of writing your own sql), you should not complain. Beggars can't be choosers. I agree its horrible code, but its meant to be a general template. The real question is why are you letting someone ELSE write your SQL instead of writing it yourself???
Admin
Poor Scott. Seems like he tried to prove his loyalty to the management by implementing all their requests until the last moment. That explains FIREDATE.
Admin
<font style="font-family: verdana;" size="1">
</font>
<font size="2">All programmers are bad. I thought that was obvious. It's amazing that the entire software industry hasn't imploded on itself yet.
</font>
Admin
I second that, programmers really are crap... Enterprise Architects on the other hand...
Admin
I admit I confused "PL/SQL developer" (from allroundautomations.com) with some other tool from a distant past. Since I don't know "PL/SQL developer", please consider my prvevious statements about it void.
Because I was toying around with the new tool from Oracle?
Admin
FascistBaby, since I usually work remotely throught a ssh shell, I use a "for" loop on the bash command line, and dump the output on a file, because I'm too lazy to copy/paste the output from my machine to the shell.
On notepad, I just have to copy/paste one of the tabulators I'm trying to replace :)
By the way, those generators you linked to are breaking on me when I replace whiskey for cussing'. Seems like the program chokes on the apostrophe character:
Admin
So it does. The code:
$if $2="fightin'" then
(i'm with you $1!!!)
$end if
becomes:
>xsl:if test='field[@number=2]="fightin'"'< (i'm with you >xsl:value-of select="field[@number=1]"/<!!!)
>/xsl:if<
Admin
I do it in Excel too for arrays of data - often the data comes in an oddball format, and using some deft Excel tools and transformations (Import as Text works wonders!), then I add columns as necessary to generate the code. Quite handy for tabular data. I often don't even bother with whitespace removal (most compilers will accept excess whitespace). And if you're generating the table, Excel helps greatly for that purpose as well.A very welcome efficiency...
Admin
Apparently they have a non-server version that runs on 3MB of disk space. Too many people who only really need TOAD or POL install Oracle Server because that 'Oracle' to them.
"Personal Oracle Light (POL) is a lightweight, single-user object/relational database that runs on desktops, laptops, down to the smallest hand help devices. It is designed for mobile and distributed applications. Some of the main features are: