The mi_switch_mem_duration() function
The mi_switch_mem_duration() function switches the current memory duration.
Syntax
MI_MEMORY_DURATION mi_switch_mem_duration(duration)
MI_MEMORY_DURATION duration;
- duration
- A value that specifies the new current memory duration. Valid
values for duration are:
- PER_ROUTINE
- For the duration of one iteration of the UDR
- PER_COMMAND
- For the duration of the execution of the current subquery
- PER_STATEMENT (Deprecated)
- For the duration of the current SQL statement
- PER_STMT_EXEC
- For the duration of the execution of the current SQL statement
- PER_STMT_PREP
- For the duration of the current prepared SQL statement
- PER_TRANSACTION (Advanced)
- For the duration of one transaction
- PER_SESSION (Advanced)
- For the duration of the current client session
- PER_SYSTEM (Advanced)
- For the duration of the database server execution
Valid in client LIBMI application? | Valid in user-defined routine? |
---|---|
Valid, but ignored | Yes |
Usage
- The user-defined routine completes.
- You change the memory duration again with another call to mi_switch_mem_duration().
- PER_ROUTINE (or PER_FUNCTION)
- PER_COMMAND
- PER_STMT_EXEC
- PER_STMT_PREP
The mi_switch_mem_duration() function does not change the memory duration for the current allocation.
The mi_switch_mem_duration() function returns the previous memory duration. You can save the previous memory duration to switch the memory duration back after performing some allocations. For example, if the memory duration was switched from PER_ROUTINE to PER_COMMAND for a particular purpose, you can invoke mi_switch_mem_duration() to switch back to PER_ROUTINE duration once PER_COMMAND is no longer required. This action can avoid unnecessary memory consumption.
For more information about memory allocation and memory durations, see the Informix® DataBlade® API Programmer's Guide.
Return values
- An MI_MEMORY_DURATION constant
- A constant that indicates the previous memory duration.
- MI_ERROR
- The function was not successful.