Hot Topic (More than 10 Replies) Importing A record with database with many forms (Read 2244 times)
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Importing A record with database with many forms
May 13th, 2013 at 6:50pm
Print Post Print Post  
I inadvertently deleted a record from a database. We have a backup copy of database but since then a lot of new records have been added, so I can not replace the whole application. If I use import -  export, it would not get certain fields of the database. A record obatain through XResultset ( ) command will have data for all the fields but then how would I make the record with all the data of all fields for that particular records?
  
Back to top
 
IP Logged
 
BOBSCOTT
Senior Member
Members
*****
Offline


That Darn Computer #$X#
{curse words}

Posts: 1195
Joined: Nov 22nd, 2002
Re: Importing A record with database with many forms
Reply #1 - May 13th, 2013 at 7:29pm
Print Post Print Post  
Bharat,

could you make a copy of the back-up, run your most recent reconcile so it now has the same structure, elements etc as your latest live version, then re-run the method that updates with xresult, then export the record and when you import it, it should be perfect.

Just a thought.
  

Team – Together Everyone Achieves More
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Importing A record with database with many forms
Reply #2 - May 13th, 2013 at 8:08pm
Print Post Print Post  
Thanks Bob for reply. I am not sure if I made myself clear. I have an application with about 9 databases in that. I, by mistake, deleted a record from one of the databases that has about 9 layouts. If I add up all the fields of these database, they are about 200 fields in 9 layouts. I cannot export the data from backup of one of the layout and import, as that would only restore the fields in that particular layout. Yes, I can do that for all layout one by one. But that would be just too much. Since xResultset ( ) command get the data of all the fields of the lost record at the same time from a backup, I think that could be utilize to reconstruct the lost record in the current application. Am I clear?  Is there any easy way to reconstruct this record from the backup?
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Importing A record with database with many forms
Reply #3 - May 13th, 2013 at 8:46pm
Print Post Print Post  
ASCII export is hierarchical. If you retrieve the one record in the top-level form, select all when exporting, you should get an ASCII file that contains the main record and all sub-records for the top level form and recursively all of their children (etc...). An import from that file, should restore the data in the main form and all of its children (etc...).

Am I not understanding the particulars of your case?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Importing A record with database with many forms
Reply #4 - May 13th, 2013 at 8:49pm
Print Post Print Post  
Do you have a record with subrecords, or do you have a record where the fields are split across multiple forms at the same level?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Importing A record with database with many forms
Reply #5 - May 13th, 2013 at 8:51pm
Print Post Print Post  
I have a record where the fields are split across multiple forms at the same level. All layouts will have fileNumber for the patient - that will be a common field for all layouts of the database. One layout will have patient's address, phone#, email, Insurance info etc, other layout will have patients regular medicines, the 3rd layout on the same fileNumber will have Immunization information, the 4th layout will have info about Last Lab, xray, colonoscopy, Mammogram etc, All these put together will will make a one record for that patient track by fileNumber and FileNumber element in each layout of the database is binded to the same field of the database.
« Last Edit: May 13th, 2013 at 10:00pm by Bharat_Naik »  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Importing A record with database with many forms
Reply #6 - May 13th, 2013 at 10:56pm
Print Post Print Post  
Something like a "master form" is needed.

Do a XLookupSourceList in a copy of the backup and retrieve all the elements from the deleted record. Save this to GlobalValue. On one of the forms make a new record and grab the data relevant to that form from the GlobalValue. Make sure you have set the shared "key" element. Save that record.

Now in each of the other forms, search so as to retrieve the newly made record. Again, use the value in GlobalValue to fill the appropriate elements and save the record.

Basically, this could be a single mass-update program you cut&paste into each form, altering the loop counter in a "for loop" so as to retrieve the correct data and uses StringArrayElementList to index into the correct elements for that form.

Alternatively, you could export from each of the nine forms. Import into nine temporary records, and then use the XResultSet commands to consolidate into a single record. Then delete the nine temporary records.

We may be able to do something more direct here by bypassing the forms and exporting/importing directly from and to records.

I am also considering some kind of "master form" facility for Sesame3. You might want to build one by hand for your nine-form record for future use.

  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Importing A record with database with many forms
Reply #7 - May 14th, 2013 at 2:04am
Print Post Print Post  
Quote:
We may be able to do something more direct here by bypassing the forms and exporting/importing directly from and to records.


This is what precisely I was hoping to do. But how? I wish xResultset ( ) command makes new records from the record handle such as vRSHandle after parsing the data it represent, as it has the complete set of data for the whole record irrespective of individual forms in the subject database.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Importing A record with database with many forms
Reply #8 - May 14th, 2013 at 12:52pm
Print Post Print Post  
You could open a XResultSet in a copy of the backup and a copy of the application to be restored and then search for the deleted record in the backup. Use XResultSetCreateNewRecord to make a new blank record in the application to be restored. Then copy each field over using field names in XResultSetValue. That would bypass the forms and element names.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Importing A record with database with many forms
Reply #9 - May 14th, 2013 at 9:32pm
Print Post Print Post  
Yes, I could reconstruct the record amicably. Thanks for your input. I used following generic code to get the data in each form using MassUpdate for just one record.

Code
Select All
var vList as String
var n as Int
var vName as String
var vCount as Int
var vReturnValue as String
var vString as String
var vStr as String



If @AskUser("Have you placed the BACK UP OF " + @Application + ".db" + " into 'c:\backup' folder?", "", "") then

	{


			Vlist = @stringArrayElementList( )
			vCount = @CountStringArray (vList)
			//WriteLn (VList)

			n = 1

			While n <= vCount
				{
					vStr = @AccessStringArray (vList, n)

					SetThisElement ( vStr)
					If @ElementBoundToType (ThisElement) >=3 and @ElementBoundToType (ThisElement) <=6 then
						{
							If vString = "" then
								{
									vString = vStr

								}
								Else
								{
									vString = vString + ";" + vStr
								}

						}


					n = n + 1

				}


			UnsetThisElement ( )


			//WriteLN (vString)


			vReturnValue  = @XLookupSourceList("C:\backup\" + @Application + ".db", RecNumber, @Layout + "!RecNumber", vString)
			//WriteLN (vReturnValue)


			vCount = @CountStringArray (vString)


			n =1
			While n <= vCount
				{
					vName = @AccessStringArray (vString, n)

					SetThisElement ( vName)
					ThisElement = @AccessStringArray (vReturnValue, n)

					n = n + 1


				}
			UnsetThisElement ( )

			@MSGBOX ("Hit F10 to save to save the record if everything is as expected", "If not, just hit escape and troubleshoot", "" )
	}
	Else
	{

		@MSGBox ("Please put backup of " + @Application + ".db " + "into c:\backup folder first", "", "" )

	}


 



Since the code is generic, I could use the same code for all the forms concerned. It was not difficult. However, I still hope to have the command or function that could work on database instead of form, that way the whole process can be completed with a single stroke.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Importing A record with database with many forms
Reply #10 - May 14th, 2013 at 11:19pm
Print Post Print Post  
Once you have all of the field names from all of the forms you could do exactly that - have one routine that does the entire record all at once.

Maybe save the field names to a file as you do it?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Importing A record with database with many forms
Reply #11 - May 15th, 2013 at 12:02pm
Print Post Print Post  
Can we have xResultset ( ) command to fetch all the field names,  Type of fields and total number of fields of the database? This would make it easier to deal with situation like this. Thanks.
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Importing A record with database with many forms
Reply #12 - May 15th, 2013 at 2:24pm
Print Post Print Post  
In Sesame 3, we have @ListFieldsByDatabase and @XListFieldsByDatabase, that do exactly that. Both return field names and types for specified databases.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: Importing A record with database with many forms
Reply #13 - May 15th, 2013 at 2:36pm
Print Post Print Post  
Thanks Mark.
  
Back to top
 
IP Logged