Hey developers! 👋 Today I want to share some insights about the delete
statement in Uniface 10.4. This powerful command is essential for database operations, but it comes with some important considerations that every Uniface developer should know.
🎯 What Does the Delete Statement Do?
The delete
statement in Uniface deletes the current occurrence from the database. Simple as that! But there's more to it than meets the eye. 🔍
📊 Return Values You Need to Know
When you execute a delete
statement, it returns different values in $status
depending on the outcome:
Value | Meaning |
---|---|
0 |
✅ Data was successfully deleted |
-1 |
❌ No entities are painted on the component |
-2 |
🔍 Occurrence not found |
-3 |
⚠️ Exceptional I/O error (hardware or software) |
-5 |
🚫 Update request for non-updatable occurrence |
-6 |
💾 Exceptional I/O error on write request |
-11 |
🔒 Occurrence already locked |
-16 |
🌐 Network error: unknown |
🔧 Error Handling with $procerror
The $procerror
variable provides additional error information:
- -2 through -12 (
UIOSERR_*
): Database I/O errors 💾 - -16 through -30 (
UNETERR_*
): Network I/O errors 🌐 - -1 (
UGENERR_ERROR
): General error - no entities painted 🎨
⚠️ Important Usage Guidelines
Here's where it gets crucial! The delete
statement should be used with care:
CAUTION: Use this statement only in the
delete
trigger and, with extreme caution, in thedeleteUp
trigger. If you place it in another trigger, make sure to lock the occurrence as soon as possible! 🔐
💡 Practical Example
Here's how you typically use the delete
statement in practice:
trigger Delete
delete
end ; Delete
Clean and simple! 🎯
🔥 Key Takeaways
- Always check the
$status
return value - Use proper error handling with
$procerror
- Stick to using
delete
in appropriate triggers - Lock occurrences when necessary for data integrity
The delete
statement is allowed in all component types, making it a versatile tool in your Uniface toolkit! 🛠️
Happy coding, and remember to always handle your database operations with care! 🚀
📚 Based on Uniface Documentation 10.4 | ✨ Created with AI assistance