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! π¬
Top comments (0)