Please help me!!! - Mailing list pgsql-general

From adm
Subject Please help me!!!
Date
Msg-id a6i0dt$ldm$1@jupiter.hub.org
Whole thread Raw
List pgsql-general
I need a help. I'm new in PL programming.
I need a following.
I have  tables:
1) users
username|balance
2) tariff
planname|dayprice|nightprice
there are day prices and night prices
3) timeplan
planname|dstarttime|dstoptime|nstarttime|nstoptime
there are a time when dayprice, nightprice begins and stops to work.

I need to create a value "session-timeout" according to users balance that
is obatained as follows:

session-timeout=balance/price*3600 (in seconds, prices per hour)
the price must be chosen according to time of day.
and session-timeout must be calculated until the balance become 0 or below
zero.
for example:
the connection began in 6.00, the next timeborder is 9.00, we have a 3 hour
time working with a price 2c per hour,
and the next 12 hours we work with 4c per hour (in time range 9.00-21.00).
The balance must be changinhg like this
balance=balance-3hours*price (for this moment price is 2c)
and we must control to not let the user run over his balance. WE must each
time check whether user can continue working in this timerange or not.

With best reagrds, Dinar






pgsql-general by date:

Previous
From: Mike Schroepfer
Date:
Subject: Primary Key Column Size?
Next
From: andrew.clark@sge.net
Date:
Subject: Re: Have problems with 7.1 -> 7.2 upgrade