I am struggling with a basic routine (well, for many of you it would probably be basic, but for me it is advanced).
Program Overview:
I created a program that looks at the world market's financial data, and every 5 minutes add's this information to a mysql database. Easy enough right?
The hard part is I want to now upgrade this mysql database so that it monitors the *changes* in price from one time period to the next.
So here is the basic idear:
1) Program inputs epoch, timestamp, last price, and now, price change into mysql database.
2) 5 minutes goes by, this program goes out on the web and collects the same data. Only this time, it looks at the previous record to get the price that was entered 5 minutes before.
3) It runs a price change percentage equation (p2 - p1)/p1, and inserts that along with the latest price into my table.
4) Repeat
I am inserting about 9 new record sets everytime this routine runs, so I would like to keep it as short and sweet as possible. I know I could run a select statement and query the database to get "lastinsert id", but I'm not sure if that is the fastest way to do it.
Thanks for any advice!
I love it when a program comes together - jdhannibal
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.