Click here to Skip to main content
15,887,267 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: JavaScript Conditional Pin
Lutosław27-Jun-10 1:12
Lutosław27-Jun-10 1:12 
GeneralRe: JavaScript Conditional Pin
whatrevolution27-Jun-10 3:18
whatrevolution27-Jun-10 3:18 
GeneralRe: JavaScript Conditional Pin
jsc4222-Jul-10 23:35
professionaljsc4222-Jul-10 23:35 
GeneralRe: JavaScript Conditional Pin
whatrevolution23-Jul-10 9:36
whatrevolution23-Jul-10 9:36 
GeneralWhat a trigger Pin
Bernhard Hiller22-Jun-10 23:39
Bernhard Hiller22-Jun-10 23:39 
GeneralRe: What a trigger Pin
Chris Meech23-Jun-10 6:16
Chris Meech23-Jun-10 6:16 
GeneralRe: What a trigger Pin
David Skelly23-Jun-10 22:52
David Skelly23-Jun-10 22:52 
GeneralRe: What a trigger Pin
Bernhard Hiller23-Jun-10 20:16
Bernhard Hiller23-Jun-10 20:16 
Maybe Oracle is not such known here, so let me give you some more explanations.
With SQL Server or MS Access, we often use "automatic IDs", that is an integer with the "Identity" property (SQL Server) set to true or the "New Values" property set to "increment". When you then insert a row, you do not care for the identifier in the table, the database generates that automatically, and from a program you can query it with SELECT @@IDENTITY.
Oracle cannot do that. You need a NUMBER column, then a "sequence" which will feed the new numbers, and a trigger for the INSERT event, which will call the sequence's NEXTVAL (next new number) and put that into the new row's ID column. From a program, you can query that value with SELECT MYSEQUENCE.CURRVAL FROM DUAL.
The above trigger was automatically generated by Oracle for the migration of an SQL Server database. When you do a migration, (most) tables do already contain some rows, and hence the trigger must be adjusted to the existing values. That's is to be accomplished by the "IF v_newVal = 1 THEN" section.
And that section's code is terrible, and - as proofed above - wrong when the table was still empty. Not only do they call the sequence's NEXTVAL as often as the maximum ID value of the table, in case of a previously empty table the ID value is set to 1 while the sequence's CURRVAL is already 2.
GeneralRe: What a trigger Pin
Covean23-Jun-10 23:20
Covean23-Jun-10 23:20 
GeneralDeliberate Crash Pin
ARopo16-Jun-10 4:01
ARopo16-Jun-10 4:01 
GeneralRe: Deliberate Crash Pin
rentzk16-Jun-10 6:18
rentzk16-Jun-10 6:18 
GeneralRe: Deliberate Crash Pin
Chris Meech16-Jun-10 6:40
Chris Meech16-Jun-10 6:40 
GeneralRe: Deliberate Crash Pin
Stryder_116-Jun-10 8:37
Stryder_116-Jun-10 8:37 
GeneralRe: Deliberate Crash Pin
ARopo16-Jun-10 23:41
ARopo16-Jun-10 23:41 
GeneralRe: Deliberate Crash Pin
Steve Wellens18-Jun-10 17:48
Steve Wellens18-Jun-10 17:48 
GeneralRe: Deliberate Crash Pin
ARopo21-Jun-10 6:04
ARopo21-Jun-10 6:04 
GeneralRe: Deliberate Crash Pin
Stephen Hewitt20-Jun-10 15:03
Stephen Hewitt20-Jun-10 15:03 
GeneralRe: Deliberate Crash Pin
ARopo21-Jun-10 6:11
ARopo21-Jun-10 6:11 
GeneralTidying up PinPopular
AnnieMacD14-Jun-10 13:03
AnnieMacD14-Jun-10 13:03 
GeneralRe: Tidying up Pin
Dr.Walt Fair, PE14-Jun-10 13:33
professionalDr.Walt Fair, PE14-Jun-10 13:33 
GeneralRe: Tidying up Pin
Dan Mos14-Jun-10 14:33
Dan Mos14-Jun-10 14:33 
GeneralRe: Tidying up Pin
PIEBALDconsult14-Jun-10 16:56
mvePIEBALDconsult14-Jun-10 16:56 
GeneralRe: Tidying up Pin
elchupathingy14-Jun-10 18:56
elchupathingy14-Jun-10 18:56 
GeneralRe: Tidying up Pin
Yusuf15-Jun-10 12:11
Yusuf15-Jun-10 12:11 
GeneralRe: Tidying up Pin
AnnieMacD15-Jun-10 12:20
AnnieMacD15-Jun-10 12:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.