Hello Ravi,

Note, in case of general SQL or MySQL-related questions, you will
probably get better answers on http://stackoverflow.com. As a general
rule of thumb, you can do everything with jOOQ, that you could do with
plain SQL. But you have to have an idea about the SQL statement
first...

>    - Now at the time of new record, i want GAME_ID to auto populate to the
>    max+1 i.e MAX(GAME_ID)+1 or COUNT(GAME_ID)+1 .

Use MySQL's AUTO_INCREMENT functionality on the GAME_ID column:
http://dev.mysql.com/doc/refman/5.5/en/create-table.html
http://dev.mysql.com/doc/refman/5.5/en/example-auto-increment.html

>    - Also, i am creating the new record at first and then updating the
>    record at a later stage when the GAME is completed. At that time, i am
>    updating GAME_END TIMESTAMP. Is there anyway, i can also update the
>    PLAY_TIME = GAME_START-GAME_END (in seconds)--

There are many ways to achieve this, both in SQL or in Java.

SQL:
- You can create a TRIGGER to always set PLAY_TIME = GAME_END -
GAME_START
- You can remove the PLAY_TIME field from the TABLE, and create a VIEW
that calculates PLAY_TIME on the fly
- You can calculate the difference at any insertion / update of data

Java:
- You can calculate the difference before insertion / update of data
and then insert / update the value as a constant. That might be the
easiest solution for you.

Reply via email to