Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Raimonds Simanovskis
RE: assign NULL bind value to object type vars [ reply ]  
2010-12-10 11:07
I verified that with ruby-oci8 trunk version I now can bind NULL values to object type parameters (no changes were needed in ruby-plsql).

See also https://github.com/rsim/ruby-plsql-spec/issues/#issue/7/comment/602199

By: Wiehann Matthysen
RE: assign NULL bind value to object type vars [ reply ]  
2010-12-06 04:31
Ok, will then have to wait for this to be solved on both ends then.

By: Kubo Takehiro
RE: assign NULL bind value to object type vars [ reply ]  
2010-12-06 04:04
> Thanks, I will try out the patch.

Well, the patch won't fix your issue.
It needs more work on both ruby-oci8 and ruby-plsql.

By: Wiehann Matthysen
RE: assign NULL bind value to object type vars [ reply ]  
2010-12-05 23:22
Hi Kubo,

Thanks, I will try out the patch.

Regards,

Wiehann

By: Kubo Takehiro
RE: assign NULL bind value to object type vars [ reply ]  
2010-12-03 13:00
I have made a patch for it.

https://gist.github.com/726904

It fixes one of the two problems pointed by Raimonds at the top of this topic.
cursor.bind_param(:address, nil, TAddress) works fine now.

By: Wiehann Matthysen
RE: assign NULL bind value to object type vars [ reply ]  
2010-11-30 23:07
Hi Kubo,

I'm making use of ruby-plsql and ruby-plsql-spec in a project of mine and they depend on ruby-oci8. I am stuck with this issue as I want to write ruby code for plsql procedures and functions that accept object types as parameters and I want to be able to pass NULL values to those procedures and functions for testing purposes. Is there a way that this can be done? Any help would be greatly appreciated. I opened the issue against ruby-plsql-spec (as Raimonds mentioned in the previous post).

Regards,

Wiehann

By: Raimonds Simanovskis
RE: assign NULL bind value to object type vars [ reply ]  
2010-11-30 15:59
Kubo,

Do you have any new ideas how to fix this issue?
I have one bug reported for ruby-plsql-spec library which is caused by this issue (https://github.com/rsim/ruby-plsql-spec/issues#issue/7)

Regards,
Raimonds

By: Kubo Takehiro
RE: assign NULL bind value to object type vars [ reply ]  
2009-11-15 22:54
> Any ideas how to correctly pass NULL values for object type variables?

It cannot be done. I did a temporary fix but it caused another problem.
I'll fix it probably next year after refactoring the object support.

By: Raimonds Simanovskis
assign NULL bind value to object type vars [ reply ]  
2009-11-04 13:42
When implementing object type support for ruby-plsql I found one other issue that I cannot bind nil (NULL) value for nested object types. And also when I assign nil bind value to plain object type variable it still is not null.

See my sample test below:
------------
require 'rubygems'
gem 'ruby-oci8', '=2.0.3'
require 'oci8'

conn = OCI8.new('hr', 'hr', 'orcl')

conn.exec "DROP TYPE t_employee" rescue nil
conn.exec <<-SQL
CREATE OR REPLACE TYPE t_address AS OBJECT (
street VARCHAR2(50),
city VARCHAR2(50),
country VARCHAR2(50)
)
SQL
conn.exec <<-SQL
CREATE OR REPLACE TYPE t_employee AS OBJECT (
employee_id NUMBER(15),
first_name VARCHAR2(50),
last_name VARCHAR2(50),
hire_date DATE,
address t_address
)
SQL

class TAddress < OCI8::Object::Base
set_typename "T_ADDRESS"
end
class TEmployee < OCI8::Object::Base
set_typename "T_Employee"
end

puts "Create new address object"
address = TAddress.new(conn, :street => 'street', :city => 'city', :country => 'country')

puts "Create new employee object"
employee = TEmployee.new(conn, :employee_id => 1, :first_name => 'First', :last_name => 'Last',
:hire_date => Date.today, :address => address)

puts "Create new employee object with NULL address - this will fail"
begin
employee = TEmployee.new(conn, :employee_id => 1, :first_name => 'First', :last_name => 'Last',
:hire_date => Date.today, :address => nil)
rescue OCIError => e
puts e.to_s
end

puts "Create new employee object with empty address - this works but is not what I want"
employee = TEmployee.new(conn, :employee_id => 1, :first_name => 'First', :last_name => 'Last',
:hire_date => Date.today, :address => TAddress.new(conn))


puts "How can I assign NULL bind value to object type variable? (this is not assigning NULL)"
cursor = conn.parse <<-SQL
DECLARE
l_address T_ADDRESS;
BEGIN
l_address := :address;
IF l_address IS NULL THEN
:result := 'IS NULL';
ELSE
:result := 'IS NOT NULL';
END IF;
END;
SQL
cursor.bind_param(:address, nil, TAddress)
cursor.bind_param(:result, nil, String, 10)
cursor.exec
puts "result #{cursor[:result]}"
cursor.close

conn.logoff
------------

Any ideas how to correctly pass NULL values for object type variables?

Raimonds