Working with disconnected data sets is a common challenge in enterprise applications. Today, let's dive deep into Uniface's reconnect
command - a powerful tool for merging XML, JSON, or Struct data back with live component occurrences and database connections. 🚀
This article is based on the official Uniface Documentation 10.4 and was created with AI assistance to help developers understand this essential command better.
📋 What is reconnect?
The reconnect
command resolves modification state information stored in occurrence metadata after loading data using xmlload
, webload
, or structToComponent
statements.
🔧 Syntax
reconnect {/readcheck} {EntityName}
⚙️ Parameters & Qualifiers
- /readcheck (optional): Ignores user modifications on read-only fields and restores values from database
- EntityName (optional): String specifying the component entity name
🎯 How It Works
The reconnect process follows a specific procedure based on occurrence modification states:
$occstatus | $occmod | $storetype | $occdel | Description |
---|---|---|---|---|
"" | 1 | 1 | 0 | 🆕 Treated as new occurrence |
"new" | 1 | 1 | 0 | 🆕 New occurrence |
"est" | 0 | 0 | 0 | ✅ Existing unmodified occurrence |
"mod" | 1 | 0 | 0 | ✏️ Existing modified occurrence |
"del" | X | X | 1 | 🗑️ Marked as deleted occurrence |
🔒 Read-Only Field Handling
Fields become read-only when:
- Field syntax definition specifies NED (no edit allowed) 🚫
- Field syntax changed to NED at runtime via
fieldsyntax
or$fieldsyntax
Using the /readcheck
qualifier will ignore user modifications to read-only fields and restore original database values. 🔄
📊 Return Values
- 0: ✅ Successful reconnection
- >0: ❌ Number of errors encountered (negative error trigger returns)
⚡ Performance Benefits
The reconnect statement intelligently merges only disconnected occurrences with modification states other than "est". This approach:
- 🚀 Improves performance significantly
- 🛡️ Avoids unnecessary CRC errors on unmodified occurrences
- 🎯 Uses ID property for efficient merging
💡 Practical Example
; Basic reconnect example
xmlload "/data/customer_updates.xml", "CUSTOMERS"
reconnect
; Reconnect with read-check for specific entity
xmlload "/data/orders.xml", "ORDERS"
reconnect /readcheck ORDERS
; Check the result
if ($status = 0)
message "Data successfully reconnected! ✅"
else
message "Reconnect failed with %%$status%% errors ❌"
endif
🎉 Conclusion
The reconnect
command is essential for modern Uniface applications handling disconnected data scenarios. Understanding its behavior with different occurrence states and proper use of qualifiers like /readcheck
ensures reliable data synchronization and optimal performance.
Remember: reconnect works with all component types and automatically handles validation flags, modification states, and database locking when using cautious locking mode! 🔐
Have you used reconnect in your Uniface projects? Share your experiences in the comments below! 💬