[ruby-oci8-devel] Proposal for bind_param_array function prototype
Liming Lian
liming.lian at oracle.com
Thu Dec 27 02:08:06 EST 2007
Hi Kubo,
> Yet another idea is the iteration_count is the size of bind values.
>
> cursor = conn.parse("INSERT INTO test_table VALUES(:name, :age)")
> cursor.max_array_size = 3
> cursor.bind_param_array(1, ["test1"])
> cursor.bind_param_array(2, [20])
> cursor.exec_array # iteration_count is 1 because parameter's
> # array sizes are all 1.
> cursor.bind_param_array(1, ["test2", "test3"])
> cursor.bind_param_array(2, [20, 30])
> cursor.exec_array # iteration_count is 2 because parameter's
> # array sizes are all 2.
>
Agree.
> cursor.bind_param_array(1, ["test4", "test5"])
> cursor.bind_param_array(2, [40])
> cursor.exec_array # raise an error because array sizes are not same.
>
> This may be usable than my previous idea.
>
>
For this case, do you think it is better to use following strategic: If
all the sizes of bound arrays are less than max_array_size, we will use
the largest one as the iteration_count. It is not required that all the
arrays are the same size. "nil" elements will be appended to those
shorter arrays to make them the size of iteration_count.
Example:
cursor = conn.parse("INSERT INTO test_table VALUES(:name, :age)")
cursor.max_array_size = 3
cursor.bind_param_array(1, ["test4", "test5"])
cursor.bind_param_array(2, [40])
cursor.exec_array # iteration_count is 2 because the largest parameter's
# array size are 2.
The rows inserted into the db are:
row1: test4 40
row2: test5 nil
More information about the ruby-oci8-devel
mailing list