Skip to content

Commit

Permalink
Implemented comments from Triveni and Mahendra
Browse files Browse the repository at this point in the history
  • Loading branch information
dwicinas committed Sep 19, 2023
1 parent d1f076d commit 17e3081
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ The `BIND_ARRAY` procedure binds a value or set of values to a variable in a cur

```sql
BIND_ARRAY (<c> IN NUMBER, <name> IN VARCHAR2,
<table_variable> IN { FLOAT | BLOB | |CLOB | VARCHAR2 | NUMBER | TIMESTAMP }
[,<index1> IN NUMBER, <index2> IN NUMBER)]);
<table_variable> IN { FLOAT_TABLE | BLOB_TABLE | CLOB_TABLE | VARCHAR2_TABLE | NUMBER_TABLE | TIMESTAMP_TABLE \
INTEGER_TABLE | ROWID_TABLE | TEXT_TABLE } [,<index1> IN NUMBER, <index2> IN NUMBER)]);
```

## Parameters
Expand All @@ -24,23 +24,26 @@ BIND_ARRAY (<c> IN NUMBER, <name> IN VARCHAR2,

A local variable that has been declared to be one of the following datatypes:

| Datatype | Description |
| Datatype | Description |
| ---------- | --------------- |
| <bflt_tab> | FLOAT_TABLE |
| <bl_tab> | BLOB_TABLE |
| <cl_tab> | CLOB_TABLE |
| <c_tab> | VARCHAR2_TABLE |
| <n_tab> | NUMBER_TABLE |
| <tms_tab> | TIMESTAMP_TABLE |
| <int_tab> | INTEGER_TABLE |
| <rid_tab> | ROWID_TABLE |
| <txt_tab> | TEXT_TABLE |


`index1`

Index for the table element that marks the lower bound of the range if you are binding a range. This value must be less than or equal to the value of `index2`. All elements between `index1` and `index2` are used in the bind.
Index for the table element that marks the lower bound of the range if you are binding a range. This value must be less than or equal to the value of `index2`. All elements between `index1` and `index2` are used in the bind. This is an optional parameter that can be used with three parameters or five parameters but not four.

`index2`

Index for the table element that marks the upper bound of the range.
Index for the table element that marks the upper bound of the range. This is an optional parameter that can be used with three parameters or five parameters but not four.


## Notes
Expand Down Expand Up @@ -77,12 +80,15 @@ BEGIN
END;
/

-- this will INSERT 3 rows in the table.
-- this inserts three rows using bind_array so verify them in the table.
SELECT * FROM tab_test;
col_int | col_charactervarying
---------+----------------------
10 | edb_user
11 | edb_user
12 | edb_user
-- For col_int we are passing bind_array with the size of 3 elements, and as col_charactervarying we are
-- passing bind_variable. So for all the insertions, we are using same bind_variable (edb_user).

(3 rows)
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The `BIND_VARIABLE` procedure associates a value with an `IN` or `IN OUT` bind v

```sql
BIND_VARIABLE(<c> NUMBER, <name> VARCHAR2,
<value> { BLOB | CLOB | DATE | FLOAT | INTEGER | NUMBER | TIMESTAMP | VARCHAR2 }
<value> { BLOB | CLOB | FLOAT | INTEGER | NUMBER | ROWID | TIMESTAMP | VARCHAR2 }
[, <out_value_size> NUMBER ])
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ BEGIN
DBMS_SQL.CLOSE_CURSOR(cur_id);
END;

Output:
col_long: Testing
value_length: 7

EDB-SPL Procedure successfully completed


-- Use positive offset
DECLARE
cur_id INTEGER;
Expand All @@ -86,4 +93,11 @@ BEGIN
DBMS_OUTPUT.PUT_LINE('value_length: ' || length);
DBMS_SQL.CLOSE_CURSOR(cur_id);
END;

Output:
col_long: DefineColumn
value_length: 12

EDB-SPL Procedure successfully completed

```
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ BEGIN
DBMS_SQL.CLOSE_CURSOR(cur_id);
END;

Output:
col_long: Testing
value_length: 7

EDB-SPL Procedure successfully completed

-- Use positive offset
DECLARE
cur_id INTEGER;
Expand All @@ -71,4 +77,11 @@ BEGIN
DBMS_OUTPUT.PUT_LINE('value_length: ' || length);
DBMS_SQL.CLOSE_CURSOR(cur_id);
END;

Output:
col_long: DefineColumn
value_length: 12

EDB-SPL Procedure successfully completed

```
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ EDB Postgres Advanced Server's implementation of `DBMS_SQL` is a partial impleme
| `COLUMN_VALUE(c, position, value OUT [, column_error OUT [, actual_length OUT ]])` | Procedure | n/a | Return a column value into a variable. |
| `COLUMN_VALUE_CHAR(c, position, value OUT [, column_error OUT [, actual_length OUT ]])` | Procedure | n/a | Return a `CHAR` column value into a variable. |
| `COLUMN_VALUE_RAW(c, position, value OUT [, column_error OUT [, actual_length OUT ]])` | Procedure | n/a | Return a `RAW` column value into a variable. |
| `COLUMN_VALUE_LONG(c, position, length, offset, value OUT, value_length OUT` | Procedure | n/a | Return a part of the `LONG` column value into a variable. |
| `COLUMN_VALUE_LONG(c, position, length, offset, value OUT, value_length OUT)` | Procedure | n/a | Return a part of the `LONG` column value into a variable. |
| `COLUMN_VALUE_ROWID(c, position, value OUT [ column_error OUT [, actual_length OUT ]])` | Procedure | n/a | Return a `ROWID` column in a cursor. |
| `DEFINE_ARRAY(c IN, position IN, table_variable IN, cnt IN, lower_bnd IN )` | Procedure | n/a | Define collection for column into which to fetch rows. |
| `DEFINE_COLUMN(c, position, column [, column_size ])` | Procedure | n/a | Define a column in the `SELECT` list. |
Expand Down

0 comments on commit 17e3081

Please sign in to comment.