Ask a Question related to Ruby, Design and Development.
-
Brent Harris #1
Ruby DBI Access
------=_NextPart_000_001F_01C3AF83.07D67E60
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
I am accessing an Oracle Database, and I would like for Ruby to be able to
get the exact size of the returned columns. How can I do this dynamically
if the only thing I'm given is an SQL statement?
Sincerely,
Brent Harris
Information Technology
ABA Programmer
------=_NextPart_000_001F_01C3AF83.07D67E60--
Brent Harris Guest
-
Internet access at Ruby conference
Hi, Does anyone know whether there will be (non-dial-up) Internet access available from either the hotel or the conference itself tomorrow? ... -
[ba-rb] BA-rb ( Bay Area Ruby Users Group ) - 'Generating Code in Ruby' by Jack Herrington.
Count me in again, too. -- Jos Backus _/ _/_/_/ Sunnyvale, CA _/ _/ _/ _/ _/_/_/ _/ _/ _/ _/ jos at... -
Thread safety: Serializing access to ruby interpreter- again
I recently asked about this and got answers, but here I go again: How can I efficiently serialize access to the ruby interpreter. I have to make... -
[ANN] ruby-freedb, ruby-serialport, ruby-mp3info moved to Rubyforge
http://ruby-freedb.rubyforge.org/ http://ruby-serialport.rubyforge.org/ http://ruby-mp3info.rubyforge.org/ bye! --... -
INI file access from Ruby
Hi all, if you need to parse/access INI files - what are you using? (whatever your OS/Windows ;-) may be) I tried the one coming with the... -
KUBO Takehiro #2
Re: Ruby DBI Access
"Brent Harris" <bharris@pcci.edu> writes:
You can get the data size, if you use one of the following:> I am accessing an Oracle Database, and I would like for Ruby to be able to
> get the exact size of the returned columns. How can I do this dynamically
> if the only thing I'm given is an SQL statement?
Ruby9i:
(I havn't use it. I just look at the codes.)
low-level APIs of oracle module:
ORAcursor#describe(pos)
low-level APIs of oci8 module:
param = OCIStmt#paramGet(pos)
param.attrGet(OCI_ATTR_DATA_SIZE)
param.attrGet(OCI_ATTR_SCALE)
param.attrGet(OCI_ATTR_PRECISION)
dbd_oracle returns larger size. The others can't do.
But above three APIs don't return the exact size, but return the
internal data size. Even though the datatype is 'CHAR', the retrieved
string may be larger of smaller than the stored string data if the
charsets of the client and the server are different.
While looking at Ruby9i source code, I found a bug in it.
According to the OCI manual, the datatype of OCI_ATTR_DATA_SIZE is
ub4. But it is ub2 in fact. The original code works on a little-endian
CPU, but not on a big-endian CPU.
--- varchar.c.orig 2003-07-07 09:13:18.000000000 +0900
+++ varchar.c 2003-11-22 11:01:31.000000000 +0900
@@ -18,7 +18,7 @@
Data_Get_Struct(self, oci9_define_buf, bp);
VALUE str;
oci9_handle *parm_h;
- ub4 col_size;
+ ub2 col_size;
if (argc == 1)
switch (TYPE(argv[0]))
@@ -32,7 +32,6 @@
Data_Get_Struct(rb_ary_entry(argv[0], 2), oci9_handle, parm_h);
if (OCIAttrGet(parm_h->ptr, OCI_DTYPE_PARAM, (dvoid*) &col_size, 0, OCI_ATTR_DATA_SIZE, err_h))
error_raise("Could not get column size", "varchar_initialize", __FILE__, __LINE__);
- col_size &= 0x0000ffff; /* XXX high bytes getting corrupted */
rb_hash_aset(rb_iv_get(self, "@column_info"), rb_str_new2("size"), INT2FIX(col_size));
/* prepare to receive varchar of length col_size */
bp->val = ALLOC_N(char, col_size + 1);
--
KUBO Takehiro
[email]kubo@jiubao.org[/email]
KUBO Takehiro Guest



Reply With Quote

