Are the RAW
type variables immutable in PL/SQL code? I mean can I alter specific byte of RAW
type variable just in place without memory copying?
Of course we have UTL_RAW
package with some routines appropriate for spec byte altering but it looks like all of them copy variable instance memory:
UTL_RAW.BIT_AND
UTL_RAW.BIT_OR
UTL_RAW.OVERLAY
Also this question is closely linked to effective string concatenation problem. For example in Java strings are immutable too and we have the StringBuilder for this task. I've not found clear info in Oracle docs on this. After some googling[1] the answer looks like: Yes. The RAW type variables are immutable in PL/SQL code as well as strings are. Is it really true? It would be better to have more explanation and history of this question.
References:
There's no such thing in PL/SQL as altering a specific subpart of the memory allocated to a variable. If it is a function (as is the case with the said utl_raw
routines), it always returns a new instance of a value. If it is a procedure with an in out nocopy
parameter, it might work on the reference to the argument, not on its copy, but still, the actual work inside the procedure involves copying values, not working in the same memory. (Well, OK, this does not apply to LOBs, but that's not what you've asked about.)
PL/SQL is a procedural language on top of SQL. It is designed to allow the SQL to be used procedurally, it is not designed to be superfast, supereffective. If you need to go as far as altering bytes directly in memory, you may want to use C or assembler.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With