How to Avoid Data Corruption
Moderator: Rathinagiri
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to Avoid Data Corruption
Viva Harbour, Viva HMG.
We have to make the variables (like i,j etc) inside the functions to be local. I had forgotten that.
We have to make the variables (like i,j etc) inside the functions to be local. I had forgotten that.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: How to Avoid Data Corruption
Hi Rathi,
Suppose, for multi-user environment, shall the MySql server calculate last_insert_id() for each user? Then if one user will not save the record (in case of insert), then what will happen to last_insert_id()?
May be it is too early for me to ask those questions, but I am so much excited, that I want to ask those typical problems about multi-user environment, which I have to do programatically with non-RDBMS databases!
With best regards.
Sudip
So, can I store "select last_insert_id()" into temporary code and insert that temporary code into table?Yes. And you can get the automatically incremented number by "select last_insert_id()" query for further processing.
Suppose, for multi-user environment, shall the MySql server calculate last_insert_id() for each user? Then if one user will not save the record (in case of insert), then what will happen to last_insert_id()?
May be it is too early for me to ask those questions, but I am so much excited, that I want to ask those typical problems about multi-user environment, which I have to do programatically with non-RDBMS databases!
With best regards.
Sudip
With best regards,
Sudip
Sudip
Re: How to Avoid Data Corruption
Great Rathi!
So Rathi has started "MySQL for Dummies"!!!
Sudip thanks for highlighting this issue, and good luck for exploring this new avenue.
BTW, my 2 cents:
Rathi create a fresh thread on MySQL and add these codes there. This can help many of us to give a try with a RDBMS with our applications.
And let this thread restrict itself on discussing how to avoid data corruption of dbfs. I've usually seen it happens in network environment during power failures. Instances like server gets down due to power failure (UPS/generator fails) but the clients at that time are ON and keying in the Entry modules - in such situations there is high chance of data corruption.
With regards,
Swapan
So Rathi has started "MySQL for Dummies"!!!
Sudip thanks for highlighting this issue, and good luck for exploring this new avenue.
BTW, my 2 cents:
Rathi create a fresh thread on MySQL and add these codes there. This can help many of us to give a try with a RDBMS with our applications.
And let this thread restrict itself on discussing how to avoid data corruption of dbfs. I've usually seen it happens in network environment during power failures. Instances like server gets down due to power failure (UPS/generator fails) but the clients at that time are ON and keying in the Entry modules - in such situations there is high chance of data corruption.
With regards,
Swapan
Re: How to Avoid Data Corruption
Watchout Rathi, it seems Sudip is so much excited that he has finished "bignners" level and soon will get into "advanced" questions...... yes I too want to know how you handle the concurrency issue?sudip wrote:Hi Rathi,
May be it is too early for me to ask those questions, but I am so much excited, that I want to ask those typical problems about multi-user environment, which I have to do programatically with non-RDBMS databases!
With best regards.
Sudip
Re: How to Avoid Data Corruption
No problemRathinagiri wrote:
We have to make the variables (like i,j etc) inside the functions to be local. I had forgotten that.
Thanks a lot!!!!!
(My clients already started calling me regarding fiscal year closing. And funny thing is that they always forget one thing - "BACKUP" )
Sudip
With best regards,
Sudip
Sudip
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to Avoid Data Corruption
Regarding concurrent issue:
Every connection to the MySQL server is handled in a separate thread. The connection is exclusive and last_insert_id() would give different auto increment numbers to different persons in the same network according to their increment id.
So, in a Point on Sale terminal, if two persons push the save invoice button simultaneously, the server would give invoice number (if it is auto incremented) first come first serve basis and till now FYI, I had not got any problem in this.
If you want to be sure, it is safe if we have Begin Transaction ... End Transaction (if our transaction has multiple queries).
MySQL had virtually removed the multi-user and concurrency problems in my programs. And also, indexing.
Every connection to the MySQL server is handled in a separate thread. The connection is exclusive and last_insert_id() would give different auto increment numbers to different persons in the same network according to their increment id.
So, in a Point on Sale terminal, if two persons push the save invoice button simultaneously, the server would give invoice number (if it is auto incremented) first come first serve basis and till now FYI, I had not got any problem in this.
If you want to be sure, it is safe if we have Begin Transaction ... End Transaction (if our transaction has multiple queries).
No. It is the id which can be received only after the insertion. If you want to know that id for any further processing, you can get. That's all.So, can I store "select last_insert_id()" into temporary code and insert that temporary code into table?
MySQL had virtually removed the multi-user and concurrency problems in my programs. And also, indexing.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: How to Avoid Data Corruption
Hi Rathi,
Thanks a lot! It is (concurrent issue) is now clear to me.
Regarding Begin Transaction ... End Transaction... can we do it with HMG? If yes, then nothing like it
BTW, I am archiving your messages regarding MySql in my computer
With best regards.
Sudip
Thanks a lot! It is (concurrent issue) is now clear to me.
Great!!!Every connection to the MySQL server is handled in a separate thread. The connection is exclusive and last_insert_id() would give different auto increment numbers to different persons in the same network according to their increment id.
So, in a Point on Sale terminal, if two persons push the save invoice button simultaneously, the server would give invoice number (if it is auto incremented) first come first serve basis and till now FYI, I had not got any problem in this.
If you want to be sure, it is safe if we have Begin Transaction ... End Transaction (if our transaction has multiple queries).
....
....
MySQL had virtually removed the multi-user and concurrency problems in my programs. And also, indexing.
Regarding Begin Transaction ... End Transaction... can we do it with HMG? If yes, then nothing like it
BTW, I am archiving your messages regarding MySql in my computer
With best regards.
Sudip
With best regards,
Sudip
Sudip
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to Avoid Data Corruption
Transaction processing is nothing to do with HMG. It is the work of MySQL.
We can send each statement as a SQL query like select all in one line, separated by ;.
This is the syntax for begin... end transaction. From MySQL manual:
example
In HMG we can send this like this.
With this, we can simultaneously save a transaction affecting two or more tables.
We can send each statement as a SQL query like select all in one line, separated by ;.
This is the syntax for begin... end transaction. From MySQL manual:
Code: Select all
START TRANSACTION, COMMIT, and ROLLBACK Syntax
START TRANSACTION | BEGIN [WORK]
COMMIT [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
ROLLBACK [WORK] [AND [NO] CHAIN] [[NO] RELEASE]
SET AUTOCOMMIT = {0 | 1}
Code: Select all
START TRANSACTION;
SELECT @A:=SUM(salary) FROM table1 WHERE type=1;
UPDATE table2 SET summary=@A WHERE type=1;
COMMIT;
Code: Select all
qsuccess := miscsql(dbo,"START TRANSACTION;SELECT @A:=SUM(salary) FROM table1 WHERE type=1;UPDATE table2 SET summary=@A WHERE type=1;COMMIT;")
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: How to Avoid Data Corruption
Hi Rathi,
I don't know how do you understand exactly what I want?
Thanks a lot!
With best regards.
Sudip
I don't know how do you understand exactly what I want?
Thanks a lot!
With best regards.
Sudip
With best regards,
Sudip
Sudip
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to Avoid Data Corruption
Because, I had also struggled like you.sudip wrote: I don't know how do you understand exactly what I want?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.