[ruby-oci8-devel] Proposal for bind_param_array function prototype

Liming Lian liming.lian at oracle.com
Wed Dec 19 01:29:41 EST 2007


Hi Kubo,
> 1. OCI8::Cursor#max_array_size = positive_number
>
>   Users can call max_array_size= many times during Cursor process. But
>   every time at calling max_array_size= all the binds are clear from the
>   Cursor. In that situation, they have to re-bind all the parameter array.

Do you mean, the binds should be clear even the new value of 
max_array_size is equal to the old one? Take a look at following example:

cursor = conn.parse("INSERT INTO test_table VALUES(:name, :age)")
cursor.max_array_size = 3
cursor.bind_param_array(1, ["test1", "test2", "test3"])
cursor.bind_param_array(2, [20, 21, 22])
cursor.max_array_size = 3
cursor.exec_array

IMO, this should be a correct usage.  Users don't need to re-bind the 
parameter since the max_array_size doesn't change.


> 2. OCI8::Cursor#bind_param_array(key, var_array, type = nil, max_item_length = nil)
>
>   If batch_size= is not called, an error is raised.

I guess you mean "max_array_size=" here, right?

>   If the size of var_array is less than max_array_size, the rest values
>   are NULL.
>   

I am considering if it is proper to insert nil values that users may not 
want. Example:

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

The rows inserted to "test_table" are
row1: test1, 20
row2: NULL, NULL
row3: NULL, NULL

I am not sure if users would be happy on those rows full of useless NULL 
values.

> 4. OCI8::Cursor#exec_array(iteration_count = nil)
>
>   If iteration_count is nil, max_array_size is used instead.
>   If iteration_count > max_array_size, an error is raised.
>
>   
Thanks kubo, here you gave me the answer to my previous worry. If users 
don't want to insert rows with full NULL values, they can add a 
parameter iteration_count  to exec_array.

Liming


More information about the ruby-oci8-devel mailing list