[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] ruby-oci8 0.1.10

KUBO Takehiro

3/23/2005 4:01:00 PM

Hi,

I've released ruby-oci8 0.1.10.
This is a Oracle module using OCI8 API.

URL:http://rubyforge.org/projects/...

What's new:

1. bind a ref cursor as an OCI8::Cursor or a DBI::StatementHandle.
(requested by Stephen Flinter and Jason Sweat.)

Example:

# parse PL/SQL
plsql = conn.parse("BEGIN OPEN :cursor FOR SELECT * FROM emp; END;")
# bind :cursor as OCI8::Cursor
plsql.bind_param(':cursor', OCI8::Cursor)
# execute
plsql.exec
# get a bind value, which is an OCI8::Cursor.
cursor = plsql[':cursor']
# fetch results from the cursor.
while r = cursor.fetch()
puts r.join(',')
end

or

# parse/bind/execute PL/SQL
sth1 = dbh.execute("BEGIN OPEN ? FOR SELECT * FROM emp; END;", DBI::StatementHandle)
# get a bind value, which is a DBI::StatementHandle.
sth2 = sth1.func(:bind_value, 1)
# fetch results from the statement handle.
while r = sth2.fetch()
puts r.join(',')
end

Restriction:
* bind a ref cursor as output, but not as input.
That means you can get it from a pl/sql block, can't pass it to
the block.

2. bind LONG / LONG RAW as 65535-byte String.
(suggested by Graham Jenkins.)

Restriction:
* If the length is longer than 65535, I don't know what happen.
I haven't tested yet. (Sorry)

3. customizable default column data type of select statements.

Many people (Dmitry Maksyoma, Maik and Graham Jenkins) have requested
to support TIMESTAMP. But I haven't supported it yet. Though you can
fetch a TIMESTAMP data as an OraDate by adding the following code to
your code.

OCI8::BindType::Mapping[OCI8::SQLT_TIMESTAMP] = OCI8::BindType::OraDate

To fetch a DATE(oracle) as a Time(ruby).

OCI8::BindType::Mapping[OCI8::SQLT_DAT] = OCI8::BindType::Time

To fetch a NUMBER(oracle) as a Float(ruby) at all times.

OCI8::BindType::Mapping[OCI8::SQLT_NUM] = OCI8::BindType::Float


4 Answers

KUBO Takehiro

3/24/2005 9:15:00 AM

0

Sorry. Some bugs was found in ruby-oci8 0.1.10.
I've released ruby-oci8 0.1.10.1.
Please use it instead of 0.1.10.

KUBO Takehiro <kubo@jiubao.org> writes:

> Hi,
>
> I've released ruby-oci8 0.1.10.
> This is a Oracle module using OCI8 API.
>
> URL:http://rubyforge.org/projects/...
>
> What's new:
>
> 1. bind a ref cursor as an OCI8::Cursor or a DBI::StatementHandle.
> (requested by Stephen Flinter and Jason Sweat.)
>
> Example:
>
> # parse PL/SQL
> plsql = conn.parse("BEGIN OPEN :cursor FOR SELECT * FROM emp; END;")
> # bind :cursor as OCI8::Cursor
> plsql.bind_param(':cursor', OCI8::Cursor)
> # execute
> plsql.exec
> # get a bind value, which is an OCI8::Cursor.
> cursor = plsql[':cursor']
> # fetch results from the cursor.
> while r = cursor.fetch()
> puts r.join(',')
> end
>
> or
>
> # parse/bind/execute PL/SQL
> sth1 = dbh.execute("BEGIN OPEN ? FOR SELECT * FROM emp; END;", DBI::StatementHandle)
> # get a bind value, which is a DBI::StatementHandle.
> sth2 = sth1.func(:bind_value, 1)
> # fetch results from the statement handle.
> while r = sth2.fetch()
> puts r.join(',')
> end
>
> Restriction:
> * bind a ref cursor as output, but not as input.
> That means you can get it from a pl/sql block, can't pass it to
> the block.
>
> 2. bind LONG / LONG RAW as 65535-byte String.
> (suggested by Graham Jenkins.)
>
> Restriction:
> * If the length is longer than 65535, I don't know what happen.
> I haven't tested yet. (Sorry)
>
> 3. customizable default column data type of select statements.
>
> Many people (Dmitry Maksyoma, Maik and Graham Jenkins) have requested
> to support TIMESTAMP. But I haven't supported it yet. Though you can
> fetch a TIMESTAMP data as an OraDate by adding the following code to
> your code.
>
> OCI8::BindType::Mapping[OCI8::SQLT_TIMESTAMP] = OCI8::BindType::OraDate
>
> To fetch a DATE(oracle) as a Time(ruby).
>
> OCI8::BindType::Mapping[OCI8::SQLT_DAT] = OCI8::BindType::Time
>
> To fetch a NUMBER(oracle) as a Float(ruby) at all times.
>
> OCI8::BindType::Mapping[OCI8::SQLT_NUM] = OCI8::BindType::Float


Dido Sevilla

3/26/2005 3:04:00 PM

0

On Thu, 24 Mar 2005 01:01:13 +0900, KUBO Takehiro <kubo@jiubao.org> wrote:
> Hi,
>
> I've released ruby-oci8 0.1.10.
> This is a Oracle module using OCI8 API.
>
> URL:http://rubyforge.org/projects/...

Will this build against the Oracle Instant Client? The only reason why
I haven't used this code in the past and am currently using the
(apparently presently unmaintained) Ruby9i extension and struggling
with some of its bugs is because I previously found it too much work
to build ruby-oci8 against the Instant Client (10.1.0.3). While the
Instant Client libraries are indeed 40+ megs in size, they consist of
only three rpm files (including the ever-handy sqlplus), and are as
such a lot easier to install than an indeterminate amount of the
Oracle RDBMS wherever I need Oracle access.

I'd rather use well maintained code than have to deal with more bugs
in what is for all purposes abandoned code the future. Or at least
have you got some hints on how to use it with the Instant Client?


KUBO Takehiro

3/28/2005 3:59:00 PM

0

Dido Sevilla <dido.sevilla@gmail.com> writes:

> On Thu, 24 Mar 2005 01:01:13 +0900, KUBO Takehiro <kubo@jiubao.org> wrote:
>> Hi,
>>
>> I've released ruby-oci8 0.1.10.
>> This is a Oracle module using OCI8 API.
>>
>> URL:http://rubyforge.org/projects/...
>
> Will this build against the Oracle Instant Client? The only reason why
> I haven't used this code in the past and am currently using the
> (apparently presently unmaintained) Ruby9i extension and struggling
> with some of its bugs is because I previously found it too much work
> to build ruby-oci8 against the Instant Client (10.1.0.3). While the
> Instant Client libraries are indeed 40+ megs in size, they consist of
> only three rpm files (including the ever-handy sqlplus), and are as
> such a lot easier to install than an indeterminate amount of the
> Oracle RDBMS wherever I need Oracle access.
>
> I'd rather use well maintained code than have to deal with more bugs
> in what is for all purposes abandoned code the future. Or at least
> have you got some hints on how to use it with the Instant Client?

Yes. Please read README in ruby-oci8-0.1.10.1.tar.gz.
It has been compiled successfully in my environment.
But I received a mail saying it failed on Redhat Linux.
Please mail me the last 100 lines of 'ext/oci8/mkmf.log' when you failed.

--
KUBO Takehiro
email: kubo@jiubao.org
web: http://www....
GnuPG fingerprint = 5F7B C8EF CA16 57D0 FDE1 9F47 C001 1F93 AC08 2262


Dido Sevilla

3/28/2005 11:57:00 PM

0

On Tue, 29 Mar 2005 00:59:14 +0900, KUBO Takehiro <kubo@jiubao.org> wrote:
> Yes. Please read README in ruby-oci8-0.1.10.1.tar.gz.
> It has been compiled successfully in my environment.
> But I received a mail saying it failed on Redhat Linux.
> Please mail me the last 100 lines of 'ext/oci8/mkmf.log' when you failed.
>

Excellent. Works like a charm on both Gentoo and FC3, even without
the LD_PRELOAD black magic that seems to be unstable on the latter
platform.