Working with Uniface ProcScript can be incredibly powerful, especially when you need to manipulate data occurrences efficiently. Today, let's dive deep into one of the most useful statements for data manipulation: moveocc
! π
This article is based on the official Uniface documentation 10.4 and was created with the assistance of AI to ensure comprehensive coverage of the topic.
π― What is moveocc?
The moveocc
statement is your go-to tool when you need to move field values from the current occurrence to another occurrence within an entity. Think of it as a sophisticated "cut and paste" operation that not only moves data but also handles all the underlying modification flags and validation states automatically.
π Syntax Breakdown
The moveocc
statement comes in two flavors:
moveocc {Entity,} OccurrenceNumber {, FieldList}
moveocc/allfields Entity, OccurrenceNumber
π§ Parameters Explained
Parameter | Type | Description |
---|---|---|
Entity | String | Entity name (optional - uses current entity if omitted) |
OccurrenceNumber | Number | Target occurrence number (integer values only) |
FieldList | String | Comma-separated list of fields to move |
ποΈ The /allfields Qualifier
When you use the /allfields
qualifier, all fields from the current occurrence are moved to the target occurrence. It's like saying "move everything!" π¦
π‘ Practical Example
Here's a real-world scenario where moveocc
shines:
operation uupdate ENT
params
occurrence pEntity :IN
endparams
findkey pEntity
moveocc pEntity, $result, $fields$
end ; end occurrence
This example demonstrates updating an entity by finding an occurrence with the same key and moving specified fields to it. Clean and efficient! β¨
π What Happens Behind the Scenes
When you execute moveocc
, several important things happen automatically:
- Data Transfer: Field values move from current to target occurrence
- Current Occurrence Changes: Target becomes the new current occurrence
- Old Occurrence Cleanup: Original occurrence gets deleted
- Modification Flags:
$fieldmod
sets to 1 for all moved fields - Validation States: All relevant validation functions update accordingly
β οΈ Error Handling Like a Pro
Always check your $status
and $procerror
values:
$status | Meaning |
---|---|
< 0 | Error occurred - check $procerror |
>= 0 | Success - returns sequence number of new current occurrence |
π¨ Common Error Codes
- -1102: Invalid entity name or entity not painted on component
- -1203: Value out of range
- -1101: Incorrect field name provided
- -302/-303: Key incorrect
π¨ Best Practices
- Always validate inputs: Check entity names and field lists before execution
- Handle errors gracefully: Implement proper error checking
- Use meaningful variable names: Makes debugging much easier
- Consider performance: Moving large field sets can impact performance
π Component Compatibility
Good news! moveocc
works in all component types except Dynamic and Static Server Pages. This gives you flexibility across most of your Uniface applications.
π― Conclusion
The moveocc
statement is an incredibly powerful tool for data manipulation in Uniface. Whether you're updating records, consolidating data, or implementing complex business logic, understanding how to use moveocc
effectively will make your ProcScript code more efficient and maintainable.
Remember to always handle errors properly and test thoroughly with your specific use cases. Happy coding! π
Top comments (0)