Start New Discussion within our Software Development Community

Hi there guys can someone explain to me how I can increment a value within a field in my database each time I execute my query?. As I cannot seem to find a way to do this. Below is my structure for reading + writting to my database if you need it to help me with my problem.

Also the code below updates my selected column but each time sets my playcount back to '1'. I wish to each time add 1 to the existing value. For instance if the value was already 1 when the query is executed the value becomes 2.

Any help would be appreciated

Code below:

String v = videoNo.getText();
             String writeString =
                     "UPDATE VIDEOS SET PLAYCOUNT = '1' WHERE VIDEOID = '"+ v + "'";
            try {
            } catch (SQLException sqle) {

Well... If it is an Oracle database,
You could have a BEFORE UPDATE trigger in the database.

Have you tried the obvious
... seems to work in ordinary SQL

Solved it but thanks for reply code I used was:

int c = sta.executeUpdate("UPDATE VIDEOS SET PLAYCOUNT = PLAYCOUNT + 1 WHERE VIDEOID = '"+ v + "'");
This question has already been answered. Start a new discussion instead.