Hi, not sure if this is what you are asking, but in Oracle, you would want to create a sequence, lets call it id_seq, and you would insert id_seq.nextval into the table, which would always return the next unique ticket number. Check the oradocs on sequences, should be no prob.
Hope this helps,
-malloc
UPDATE:
Cubes made an excellent point about wasting empty rows in the main table and transactional support. I would handle this by first popping the top value off of the sequence with something like
$id = "select id_seq.nextval from dual"
and storing that in your script, and only inserting that value into the database when the user "stumbits" the ticket.