can anybody explain what is the main difference between functions and procedures in Oracle? Why must I use procedures if I can do everything with functions?
State-changing vs non-state-changing
On top of Romo Daneghyan's answer, I've always viewed the difference as their behaviour on the program state. That is, conceptually,
Ie, if you called a function named generateId(...)
, you'd expect it to only do some computation and return a value. But calling a procedure generateId ...
, you might expect it to change values in some tables.
Of course, it seems like in Oracle as well as many languages, this does not apply and is not enforced, so perhaps it's just me.