Hot Topic (More than 10 Replies) Copying / Moving records between databases (Read 1809 times)
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Copying / Moving records between databases
Feb 6th, 2011 at 3:36am
Print Post Print Post  
I have a two-part question which basically involves the same issues.

We have a QA database with 9 "History" screens containing text. I have translated that to Sesame and I will be merging the separate fields into one long one.

Those are in a Status database.  Every day, changed records are copied to a Past Status database for archival purposes.  In other words, whereas there is only one File No 123456 in QA (and eventually the new Sesame version Status), Past Status could have dozens of records with that number, providing an archival history of changes sortable by Last Update.  In QA those records are Copied from Status to Past Status.

It seems the only way to transfer data from one Sesame db to a different one is with CSV export/import.  However, the User Guide says at page 352:

Export Limits
There are no limits on the number of fields, the number of records, or the total output
file size. There is a limit of 4Kb for a single field, in a single record. So if you have a
comments field and for one record there is over 4k of text in it, that will be truncated.


I suppose there is a kludgy way to write the entire field to a text file with a unique ID, pass that ID to the receiving program, and then have the receiving program read in that file, insert it into the (duplicate format) field, save it, and delete the kludge file.  But that seems an awful mess for something that should be pretty easy--copying records in the program's native record format. Plus, I have added several new text fields (emails/letters to clients, in-house emails, and "General Storage" for "things that just don't elsewhere"), so it would involve writing about 4-6 files per record.

Creating a subform with individual records by date isn't really an option--various people often have to read through all the notes searching for "something we didn't notice before".
  
Back to top
 
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Copying / Moving records between databases
Reply #1 - Feb 6th, 2011 at 4:48am
Print Post Print Post  
I suspect that that is an archaic limitation and is no longer true. I just exported form with a text field containing over 60K bytes with no problem. So, I suggest you give it a try as-is. We'll make a note for the next printing of the manuals and make sure it appears in the errata section.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Copying / Moving records between databases
Reply #2 - Feb 7th, 2011 at 3:52am
Print Post Print Post  
I did some testing and there is a "sort-of" limit than can be overcome with a simple filter.

A text field up to 100,000 characters (a-z and A-Z) exports without changes. A field with 100,020 characters or more adds Chr$(13)\n after every 97th character. (According to Notepad ++ v. 5.8.2 (UNICODE))

The same happened with fields containing 200k, 300k, 500k and 1,000,000 characters.  The files with multiples of 100k consisted entirely of lower and uppercase letters.  The 200k+ files consisted of a copy/paste of the 100k file done in Windows XP Notepad saved as a file, then those files copied and pasted to new Sesame records, so the text was identical--just more of it.

The extra characters in 100,020 and 100,050-character files consisted of 0-9, i.e., the files only contained alphanumeric characters and no control characters.

All exports were done from the same field in the same database, just different records.  Even the 1,000,000-character field exported without truncation.

The exported version of the 100,020-character field is 103122 characters long, i.e., 3102 added characters, 1035 lines, the final one being partial, 1034 lines with Chr$(13)\n.

I tried re-importing the 200k field but it only took the first 97 characters.  I loaded the same file into Notepad ++ and used Extended replace to replace \r\\n (note the 2 slashes before n) with nothing.  The entire 200k field then imported.

So, if any individual field exceeds 100,000 characters, the CSV file must be run through a filter before being imported. Exports and Imports of million-plus character fields should be possible, since the same characters were added at the same interval for all fields over 100,000 characters. When exporting text fields containing blank lines, Sesame adds the characters \n but they are not preceded by Chr$(13) and the end-of-record separator won't be preceded by the \n characters, so the filter will not affect anything else.

Another interesting application of this is that a simple uuencode/decode combo should enable storing binary data or images in a Sesame text field.
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: Copying / Moving records between databases
Reply #3 - Feb 7th, 2011 at 2:55pm
Print Post Print Post  
Hi Rick_R,

We were quite surprised to see your description of what we are doing on export, as we are not aware of doing any such thing. Sticking a 13 into your data every 97 characters just doesn't make any sense. There's no reason why Sesame would do such a thing.

We've tested export with fields containing up to 1 million characters and aren't seeing any behavior like what you describe, nor do I see any indication of this behavior in the source code.

I suspect that the extra line breaks appearing in your data are being inserted by your word processor program.
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: Copying / Moving records between databases
Reply #4 - Feb 7th, 2011 at 2:58pm
Print Post Print Post  
How did you put the data into these fields?

Cut-and-paste in Windows, has very severe limitations, and can alter content based on assumptions about content. Additionally, the text editors available on Windows, notpad in particular, may introduce formatting to the copy buffer.

On export, Sesame will replace actual new-lines (13, 10 on Windows, just 10 on all other OSes) with figurative linefeed ("\n" / "\r") to prevent other programs (including Sesame) from breaking field mid-quoted string. Sesame knows that these exist and arranges the replacement back to true new lines on import. Since "\n" and "\r" are standard notation for a linefeeds, many other programs will also respect the intent and replace these with actual newlines as appropriate to the OS. This has nothing to do with field length.

On the other hand, almost all text editors have line length limits, and will break line automatically if these are exceeded. If you know that your export has fields exceeding the line length limit of your text editor, it is unwise to view the file in that editor as a means of determining the actual content, since it will enforce a particular maximum line length. Notepad is notorious for wrapping, truncating, and generally failing to deal with long lines (> 1024 bytes) and long files, depending on the version.

Uuencode uses base 16 (hexadecimal) to encode binary data. It is very inefficient for the encoding because it must use two bytes to encode every single byte that is encoded. You might consider using base64 encoding. Or, more simply, storing any large binary info in separate files and putting the path to that file in a text field in Sesame. Since displaying uuencoded (or base64) binary in a form is visually meaningless, unlikely to be usefully searchable, is likely to bloat the application file, and would likely need to dumped to a file to be used, it may well be better to start where you are likely to end up anyways. This basically true for any database engine, even those with block binary data types.

What sort of binary are intending to store?
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Copying / Moving records between databases
Reply #5 - Feb 8th, 2011 at 11:00pm
Print Post Print Post  
I started by typing into Notepad a thru y lowercase, copying it and converting that to uppercase, then typing in y thru a and then copying and converting that.  That gave me exactly 100 characters.  The saved file is 100 characters.  I then copied and pasted that to 1000, then the 1000 to 10000, etc.  So when I say the file had 100,000 or 500,000, etc., characters, that is the exact number.  The 1Mb file has exactly 1 million characters, being the 100k file pasted 10 times, plus my file manager shows the exact number of bytes.

Up to 100,000 exports exactly. 100,020 and up have the problem.  The files that are not exact multiples of 100k were created by taking the 100,000 file and typing in 1234567890 and then copying and pasting that.  After 050 I tried 020, which also did it.

I suspect 100,001 would also introduce the characters but I didn't try.

I'm assuming that somewhere somebody defined an array or put some other limitation, probably to avoid an overflow problem.  I tried importing and exporting a 1,000,000 alpha text.  What if someone tried a 10M or 100M text? I can easily see picking specifically 100,000.

I looked at the files with a file browser (PowerDesk 8 from Avanquest) as well as both Notepad and Notepad ++, which is a programmer's editor.  The pasting is definitely not introducing the chr$13)\n sequence.  When I paste the 1M text into Sesame it takes it fine.  The only problem is with the exported text.
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Copying / Moving records between databases
Reply #6 - Feb 9th, 2011 at 2:49am
Print Post Print Post  
I can confirm Lantica's findings that Sesame is NOT modifying the data.

I just did an import/export of a file with 1,000,500 characters, and I ended up with an exact match of what I started with. I did the test once by importing the text file, then exporting it; and again by using copy/paste to put the text into Sesame, then exporting it.

The only things extra were the opening and closing quotes, and a CR/LF after the last quote.

(I created the test data in NotePad++ by following the directions listed here. I began with 100,000 alpha characters, then added 50 numeric digits, and finally copied and pasted that until it totaled 1,000,500 total characters.)
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Copying / Moving records between databases
Reply #7 - Feb 9th, 2011 at 4:33am
Print Post Print Post  
Something I forgot to mention. I actually exported two fields every time.  The first contained the number of characters as a 7-digit text string with leading zeroes and the second was the large alphanumeric string.  The first three lines of the export are as follows (substituting * for chr$(13)):

"0100020","abcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYyxvvutsrqponmlkjihg
fedcbaYXVVUTSRQPONMLKJIHGFED*
\nCBAabcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYyxvvutsrqponmlkjihgfedcba
YXVVUTSRQPONMLKJIHG*
\nFEDCBAabcdefghijklmnopqrstuvwxyABCDEFGHIJKLMNOPQRSTUVWXYyxvvutsrqponmlkjihgfed
cbaYXVVUTSRQPONMLKJI*


The final line does end with double quote and CRLF, unlike the other lines.

By the way, the above splits differently on the post here. In Notepad ++ there are 3 lines, the first beginning with a double quote, the second two beginning with a backslash, and all three ending with a CR.
  
Back to top
 
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Copying / Moving records between databases
Reply #8 - Feb 9th, 2011 at 4:54am
Print Post Print Post  
Regarding storing binaries, I'm going to start a different topic.
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Copying / Moving records between databases
Reply #9 - Feb 9th, 2011 at 5:55am
Print Post Print Post  
Rick,

I just re-tested it, including "0100020" in another field. Same results I had earlier -- Sesame did NOT add a line break.

Just curious, exactly what type of layout elements (LEs) are these values being stored in. Are they in a single-line Text Box, multi-line Text Box, or Text Editor? Actually, I guess it doesn't matter because I've tested the large data value in all 3 of these types of LEs, and didn't notice any problems.

You must have something else causing this besides Sesame, unless you are running a different release. I'm using version 2.5.2, what version do you have?
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
Rick_R
Full Member
***
Offline



Posts: 243
Joined: Jan 29th, 2010
Re: Copying / Moving records between databases
Reply #10 - Feb 9th, 2011 at 11:19pm
Print Post Print Post  
I'm using the Personal Version 2.5.2.

I have an unrelated form command button, Test Code, which simply executes whatever is in the On Element Entry code.  I set that up to display the length of the field I have been exporting.  It shows the 200k record as exactly 200k but the 1 MB field (which I pasted in a few days ago) as larger.

I tried again pasting the 200k file into a different record and now it's exporting that correctly, although I don't think I've done anything differently!  (Even used same source file.)

I guess this is one of those "occasional weirdness" computer glitches.  From what I can tell, I doubt any one field in our application will ever get to 100k+.  So if it does come up again I'll know what to check out.
  
Back to top
 
IP Logged