Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases and the fly likes increment a number in a column? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "increment a number in a column?" Watch "increment a number in a column?" New topic

increment a number in a column?

davy nolan

Joined: Mar 20, 2001
Posts: 6
Just wondering what would be the best way to increment a number in a column in a database.The situation is that the database must record the number of hits a user makes to the site. So I must retrieve the number for the particular row for that user and increment it each time they logon to the site. Is there any one liner way of doing this? I am using the Oracle 9i database and the userid is the primary key for each row.

Davy Nolan
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
UPDATE user_hits SET hits = hits + 1 WHERE user_id = ?
Use a PreparedStatement for this so the database can cache it.
- Peter
I agree. Here's the link:
subject: increment a number in a column?
It's not a secret anymore!