Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Kubo Takehiro
RE: problem saving string data to LONG field... [ reply ]  
2010-10-27 13:15
If you bind LONG RAW columns by OCI8::Cursor#bind_param, you can pass string data as it is.

ruby-oci8 2.0:
cursor = conn.parse(sql_stmt)
cursor.bind_param(1, string_data, :raw) # bind string_data as raw.
cursor.exec

The following code works on both ruby-oci8 1.0 and 2.0.
cursor = conn.parse(sql_stmt)
cursor.bind_param(1, string_data, OCI8::SQLT_BIN) # bind string_data as raw.
cursor.exec

By: Tim Ferrell
RE: problem saving string data to LONG field... [ reply ]  
2010-10-27 12:09

Ah, yes ... that is it ... the database docs I have said LONG but in looking at the table it is LONG RAW. Thanks for the help!


By: Raimonds Simanovskis
RE: problem saving string data to LONG field... [ reply ]  
2010-10-27 10:42
Is it really LONG data type or LONG RAW data type?

Don't have access to Oracle 8 but in Oracle 10g you can insert strings without any special encoding in LONG columns but you need to use hex encoding (e.g. encode 'ABC' as '414243') if you want to insert in RAW or LONG RAW column).

By: Tim Ferrell
problem saving string data to LONG field... [ reply ]  
2010-10-26 18:27

I am working with an Oracle 8.0.6 database using ruby-oci8 1.0.7 and the original activerecord adapter that I tweaked to work with Oracle 8.

I am having a problem saving text to a LONG field - reading works fine for data that is already there, but when I go to update with a new text string I get an exception with the following message:

OCIError: ORA-01465: invalid hex number

Any ideas? Do I need to encode the string somehow?

Thanks much!