The BIND_VARIABLE procedure binds a value to a parameter. Each call to the procedure binds a value to one parameter. To bind values to multiple parameters, you must call the procedure multiple times.
In statements parsed by DBMS_SQL, parameters are identified by names. The BIND_VARIABLE procedure also binds values to parameters by name.
Applicability
This topic applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support this feature.
Syntax
DBMS_SQL.BIND_VARIABLE(cursor_id IN INTEGER,
name IN VARCHAR2,
value IN NUMBER);
DBMS_SQL.BIND_VARIABLE(cursor_id IN INTEGER,
name IN VARCHAR2,
value IN VARCHAR2);
Parameters
| Parameter | Description |
|---|---|
| cursor_id | The ID of the cursor to which you want to bind a value. |
| name | The name of the variable in the declaration. |
| value | The value to bind to the variable in the cursor. |
Considerations
If the variable is an IN or IN/OUT variable or an IN collection, the binding value must be valid for the variable type. The binding value of an OUT variable is ignored.
Binding variables in SQL statements are identified by names. When you bind a value to a binding variable, the string that identifies the value in the statement must start with a colon, as shown in the following example:
SELECT name FROM friend WHERE age > :X;
The following examples show possible binding calls in the preceding example:
BIND_VARIABLE(cursor_name, ':X', 25);
or
BIND_VARIABLE (cursor_name, 'X', 25);
