Posted on
Mastering Uniface entitycopy: Your Complete Guide to Data Migration 📊
🎯 What is entitycopy?
Theentitycopy function is a powerful batch processing instruction in Uniface 10.4 that enables you to copy one or more entity occurrences from a source database or XML file to another destination. Think of it as your Swiss Army knife for data migration tasks! 🛠️
📝 Basic Syntax
entitycopy Source, Target {, Options}
🔍 Quick Example
entitycopy "def:myent.mymodel", "xml:ABC.xml", "append=T"
⚙️ Parameters Overview
Parameter | Type | Description |
---|---|---|
Source | String | Source of data to be copied (database path, XML file, or TRX file) |
Target | String | Destination database path or XML file |
Options | String | Associative list containing operation options |
🎛️ Essential Options You Need to Know
📄 File Operations
- append=True|False - Append data to existing XML files
- keepopen=True|False - Keep files open for performance optimization
- sort=True|False - Copy output in primary key order
🗺️ Data Mapping
- map=MapFile - Use custom mapping files
- map=# - Use target repository definitions
- map=#Entity - Map specific entities
🔍 Filtering & Selection
- where=SelectClause - Copy selected occurrences based on conditions
- supersede=True|False - Overwrite existing occurrences
⚡ Performance Tuning
- printinterval=Number - Control message frequency
- commitinterval=Number - Set database commit frequency
💡 Practical Examples
🔄 Database to XML Export
; Export entity data to XML fileentitycopy "def:myent.mymodel", "xml:myexportfile.xml"; Export to compressed archiveentitycopy "def:myent.mymodel", "xml:myzip.zip:myexportfile.xml"
📥 XML to Database Import
; Import XML data to databaseentitycopy "xml:myexportfile.xml", "def:myent.mymodel"
🎯 Advanced Filtering with WHERE
; Copy organizations A-C in Detroitentitycopy "def:ORG.ORGSMODEL", "xml:ABCOrgs.xml", "printinterval=50 ;where=ORGNAME >=A&<=D!;CITY=Detroit"; Copy products with OR conditionentitycopy "def:PRODUCT.PRODUCTS", "xml:myexportfile.xml", "printinterval=50 ;where=CODE >=A &<=D !;CATEGORY|=footwear"
🚨 Error Handling & Return Values
The function returns valuable information through$procReturnContext
:
- ≥0: Success - Number of processed records
- <0: Error occurred - Check
$procerror
for details - 8066: Copy failed - Input file/table open error
📊 Return Context Information
InputRecords
- Records to be copiedOutputRecords
- Records successfully writtenSkippedRecords
- Records not writtenWriteErrorsContinues
- Non-fatal write errors
⚠️ Important Considerations
⚡ Performance Tip: Use
keepopen=True
when appending multiple datasets to improve performance, but remember to explicitly flush and close the file afterward!🔒 Security Note: The copy process doesn't consider referential integrity constraints. As a developer, you must ensure correct data copying to maintain referential integrity.
⛔ Critical Warning: Never use entitycopy for Repository definitions export/import - this can cause corruption! Use the dedicated export/import functionality instead.
🎉 Conclusion
Theentitycopy
function is an incredibly powerful tool for data migration in Uniface 10.4. Whether you're moving data between databases, creating backups, or performing bulk operations, mastering this function will significantly enhance your development workflow. 🎯
Remember to always test your copy operations in a development environment first, and pay attention to error handling and return values for robust applications! 🛡️
This guide was created with AI assistance and is based on the official Uniface Documentation 10.4. Happy coding! 🚀
Top comments(0)
For further actions, you may consider blocking this person and/orreporting abuse