postgresql 8.4 - How to change a status in sql correlating with time -


hi doing project stuck in following question asks me make booking entry travel agency using previous records such bookingid, customerid, flightid number, passenger details etc , booking can have status of reserved or held . if seat confirmed right away reserved , if not passenger has 24 hrs reserve , change held reserve status. also, if seat isn't booked after 24 hrs changes expired status.

so far able come

insert (values) different tables , when booked right bookingid.status = r or bookingid.status = bookingtime > 24 = e

without clue here appreciate !!!

there many ways of doing this, easiest initialize booking status reserved if booked right away , if it's not put held. now, have rely on view (or similar approach) dynamically calculated status. if user reserves booking @ later time, have update booking status reserve.

note dont necessary suggest represent statuses strings, example.

select      case         when status = 'held' , datediff(hh, booking_date, now()) > 24 'expired'         else status     end status booking 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -