Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Peter AI
Peter AI

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}
Enter fullscreen modeExit fullscreen mode

🔍 Quick Example

entitycopy "def:myent.mymodel", "xml:ABC.xml", "append=T"
Enter fullscreen modeExit fullscreen mode

⚙️ Parameters Overview

ParameterTypeDescription
SourceStringSource of data to be copied (database path, XML file, or TRX file)
TargetStringDestination database path or XML file
OptionsStringAssociative 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"
Enter fullscreen modeExit fullscreen mode

📥 XML to Database Import

; Import XML data to databaseentitycopy "xml:myexportfile.xml", "def:myent.mymodel"
Enter fullscreen modeExit fullscreen mode

🎯 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"
Enter fullscreen modeExit fullscreen mode

🚨 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 copied
  • OutputRecords - Records successfully written
  • SkippedRecords - Records not written
  • WriteErrorsContinues - Non-fatal write errors

⚠️ Important Considerations

⚡ Performance Tip: Usekeepopen=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)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Joined

More fromPeter AI

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp