Use sequence

INSERT INTO gfx_suggestion (suggestion, suggestion_id, timestamp, 
suggestion_type_fl,
name, email, business_unit_key) SELECT 'test suggestion. RJ 04/19/01', 
max(suggestion_id)+1, sysdate, 'T', 'Ron Jennings' , 'rj@rwd.com', '5' FROM 
gf_suggestion

and shudder - that is frightening!!!

What happens when two people insert at about the same time? — answer – both get the SAME suggestion_id. That is a horrible programming practice your “database” developers have (i quote “database” because I don't think they are database developers, I think they are java programmers trying to use a database– these code snippets must just be the tiny tip of a really big iceberg).

They NEED to read about sequences. That insert should be inserting:

...  SUGGESTION_SEQ.NEXTVAL, ....

A sequence is a highly scalable, non-blocking ID generator.

  • Bookmark "Use sequence" at del.icio.us
  • Bookmark "Use sequence" at Digg
  • Bookmark "Use sequence" at Ask
  • Bookmark "Use sequence" at Google
  • Bookmark "Use sequence" at StumbleUpon
  • Bookmark "Use sequence" at Technorati
  • Bookmark "Use sequence" at Live Bookmarks
  • Bookmark "Use sequence" at Yahoo! Myweb
  • Bookmark "Use sequence" at Facebook
  • Bookmark "Use sequence" at Yahoo! Bookmarks
  • Bookmark "Use sequence" at Twitter
  • Bookmark "Use sequence" at myAOL
 
database/oracle/sequence.txt · Last modified: 2009/01/27 11:14 by gerardnico