Jump to content
xisto Community
Sign in to follow this  
Sadas

How To Increase Digit Values Automaticaly?

Recommended Posts

Hello, I started learning MySQL today, becouse it's really powerfull tool I think... Doing great :( And here comes my first question:How to increase digits values automaticly in my database. For example: there are some kind of information. Each information line has some credits. How do I make the amount of credits increase everyday at 9am by 20%?

Share this post


Link to post
Share on other sites

Dude that is not directly possible by any command of the database. There's an autoincrement feature in MySQL. You can declare a field to automatically increase and store the incresed value when a new record is inserted. But that's it.. for what you're asking, you to write some external program, either in php/perl/.net - whatever, that fires up at 9 am using some sort of cron-job/scheduler and resets all those fields in your db by 20% increase.. I don't think it's possible to do it alone with mysql.

Share this post


Link to post
Share on other sites

So it means that MySQL can't manage the data itself? All the data handling and controls must be done with a script? If so, then the bast way to do the job would be php scripts I think... Am I right?

Share this post


Link to post
Share on other sites

So it means that MySQL can't manage the data itself? All the data handling and controls must be done with a script? If so, then the bast way to do the job would be php scripts I think... Am I right?

<{POST_SNAPBACK}>


I dont think ANY database can do that - that is manage data on it's own. All databases are designed to simply store data - alongwith that they provide you with a whole set of advanced tools and stored procedures with which you can manipulate this data as you wish. According to what I know, all sorts of manipulation instructions has to come from some external source - for example your php script or some sql source file which is fired off at a regular interval and so on..

 

Your best bet is to use php - although I've no idea how to make that php script fire-off at a specific time everyday.. alternative it to use the mysql command line client in conjunction with a source file which contains the appropriate sql commands to update your data. This whole thing has to be set down in the form of a script which is run by cron daily at some specific time... Or if you're using windows, then you can write a windows service that does the same.. That's the only way I see it happening..

Share this post


Link to post
Share on other sites

So it means that MySQL can't manage the data itself? All the data handling and controls must be done with a script? If so, then the bast way to do the job would be php scripts I think... Am I right?

<{POST_SNAPBACK}>


Any tools and programming languages will work as long as it can access the database and can be called on regular interval like every 9am.

 

on linux and nix systems, you need the cron jobs as said by the post above and for windows, you can either use or create some system services that monitors the time and fires at the given time.

 

some windows system have a tool like this called task scheduler if i am not mistaken.. sorry dude, I am not a microsoft fan so I cant answer that.. I hate it coz it got lotsa bugs..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.