473,379 Members | 1,533 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Attribute updation problem!!!

hello,
I am making an application where I have to copy the values of some of the tuples(which are not already copied into the files) from my database in MySQL into two files.Now I have an attribute with name "Replication_Done". This is an integer type of attribute and its initial value is 0, meaning that this tuple has not been copied into any of the 2 files.
Now whenever a tuple is copied into one of the file, the value of this "Replication_Done" is incremented by 1. This means from 0 to 1, and then if copied to the other, then from 1 to 2.

Now the condition is that, this whole replication mechanism may not complete in one sitting, i.e. I should be able to close my application any time I want, and then whenever I am back, it should start this replication from where it left. For example say I have 3 tuples with say primary key as "User_ID" as 1001,1002,1003 and say
Expand|Select|Wrap|Line Numbers
  1. User_ID       Replication_Done
  2. 1001            2
  3. 1002            1 
  4. 1003            0
  5.  
Now next time my application should copy the 1002 tuple to file 2 and then 1003 tuple to file 1 and file 2.
Actually I am able to achieve all these requirements, but the problem is something different.

What I do is:
I have a function named databaseStudy() and it does a study of my database and gives me information about tuples 1002 and 1003 that their value of Replication_Done are less than 2, so they should be copied to files. So for this I create a MYSQL *handle and get the values of the attributes of the tuples in say variable char tuple[5][45], as there are 5 attributes in the tables. Now in 1 iteration I copy the values of 1 tuple into this array and pass this array to another function say tupleReplicate(tuple). Now inside this function I have a for loop which copies the values of this tuple into the files, and in doing so it checks whether this tuple is already copied into that file(this is done by checking the 1st 4 chars of each line in the file), if so it skips this file and copies the tuple into the other file(again checking as above).Once a tuple is copied into any of the file, the value of Replication_Done is incremented. After the tuple is copied into both the files, this tupleReplicate(tuple) closes the MYSQL handle and returns and now the databaseStudy() again calls the tupleReplicate(tuple) for other tuples, if any of the tuple has Replication_Done less than 2.
Now the problem is I open another handle to MYSQL inside tupleReplicate(tuple) to see the value of Replication_Done as if I check the value with the value passed to this function, then its not proper as the value of Replication_Done in tuple[] array is the older value. So I reads the table again here for this User_ID. Now on 1st iteration, it gives the correct value, i.e. before copy it gives Replication_Done = 0, then after copy to 1st file, it gives Replication_Done =1. But after returning from this function, I dont know what it does, but the final value of Replication_Done is 0. Thus next time if I again starts the application, it again starts copying this tuple, which it should not do.
Please tell me a solution, or where I am doing the error. Is it because I have opened a new Handle inside the function with another handle already opened. I do close the inner handle when returning from the function.

Code is in simple C++.
Database used is MySQL

Please Reply
Pawan
Mar 15 '07 #1
0 1022

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andy Howden | last post by:
I'm trying to define a schema element (allPeriodData) containing up to 50 different decimal child elements (periodData). Each child element (periodData) identifies itself with an ID having a value...
7
by: Dennis | last post by:
This doesn't work: <head> <!-- some things snipped --> <script> function display() { alert("hey"); }
4
by: smita | last post by:
Hi, I have an xml file as below <root> <table id =1> <user>abc</user> <age>25</age> </table> <table id = 2> <user>xyz</user>
0
by: Alexandre T. | last post by:
Hi, I am currently using xsd.exe to generate C# classes from XSDs. Sample XSD file: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault=" qualified"...
1
by: Babz | last post by:
Hi, How I can prevent concurrent updation of a records in .net. I am using Dataset which is disconnected from the data source. In this situation if two users opens the same record, modifies the...
0
by: smasadhaque | last post by:
We are using a third party control C1FlexGrid to display the real time data. The data is received from a server on a different thread, processed and then stored in a dataset table. This table is...
1
by: gauravtechie | last post by:
Hi all, I have a javascript that is reloading itself on every menu change, Now the problem is that the values of the product doesn`t reset itself on catalogue change, the code is <html>...
1
by: roshan56us | last post by:
Hi, i have problem in updation of access database, which is in backend and Visual basic as front end. its using 800 records in MS-Access but,while updating the database, it doesn't update sometime...
1
by: siri11 | last post by:
Hi everyone!!!!!!!!! If i update a record in a table in sqlserver from front end (c#.net),using a stored procedure for updating then after updation if i open the table then it is showing the same...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.