[ruby-oci8-devel] Proposal for bind_param_array function prototype
kubo at jiubao.org
Sat Dec 29 07:21:56 EST 2007
Liming Lian <liming.lian at oracle.com> writes:
>> cursor.bind_param_array(1, ["test4", "test5"])
>> cursor.bind_param_array(2, )
>> cursor.exec_array # raise an error because array sizes are not same.
> 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.
> 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, )
> 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
I prefer an error in this case. I cannot imagine users try to insert
such arrays. If they make the arrays by their hands, their sizes may
not be same. But IMO, it is rare to write array data by hands.
If a program make them, it will be unexpected case. It should raise an
KUBO Takehiro <kubo at jiubao.org>
More information about the ruby-oci8-devel