kubo / ruby-oci8

Ruby-oci8 - Oracle interface for ruby
Other
169 stars 75 forks source link

Problems inserting rows #34

Closed adolfoc closed 11 years ago

adolfoc commented 11 years ago

Greetings,

I have Oracle Instant Client 11.2.0.3 installed on a MacMini running Mountain Lion (10.8.3). I am able to create, selected and insert into tables from SQLPlus. However, using Ruby 1.9.3p327 and ruby-oci8-2.1.5, I am able to select but not insert. Insert operation returns 1 (I'm assuming that means success), an immediate select returns the row (is it cached on the client?) but the row is not effectively persisted in the database, and a subsequent select from ruby or SQLPlus returns no rows.

I've checked with Wireshark that there is data going to and coming back from the server box (Windows 7 running Oracle Server Personal Edition 11g Release 2).

Any ideas? All help will be greatly appreciated.

Best regards, Adolfo

kubo commented 11 years ago

You need to commit the transaction.

conn = OCI8.new(username, password, database)
conn.exec('insert into table_name values (:1, :2)', 'foo', 'bar')
conn.commit  # The inserted row is invisible from other connections unless the transaction is committed.
adolfoc commented 11 years ago

Yup, that did it. I was looking for a commit method on cursor and never found it. Thank you very much.