# Reading oracle data type char in radio\_button

**URL:** <https://www.ruby-forum.com/t/reading-oracle-data-type-char-in-radio-button/126949>\
**Category:** Rails\
**Created:** [January 23, 2008, 6:05pm UTC](https://www.ruby-forum.com/t/reading-oracle-data-type-char-in-radio-button/126949 "2008-01-23T18:05:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![backz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9f8e36/32.png) [@backz](https://www.ruby-forum.com/u/backz)\
**Post date:** [January 23, 2008, 6:05pm UTC](https://www.ruby-forum.com/t/reading-oracle-data-type-char-in-radio-button/126949/1 "2008-01-23T18:05:52Z")

</div>

Hi,

I am having problem when I read oracle char data type on edit  
form(after saving the form and go to edit page again, all the radio  
buttons are unchecked). text\_field works fine for char data type. Is  
there any special way that I need to use for reading oracle char data  
type?

\<%= radio\_button (‘attending\_ip’, :problem\_1\_status, ‘1’) %\>  
Urgent&nbsp &nbsp  
\<%= radio\_button (‘attending\_ip’, :problem\_1\_status, ‘2’)%\>Active&nbsp  
&nbsp  
\<%= radio\_button (‘attending\_ip’, :problem\_1\_status, ‘3’)  
%\>Stable&nbsp &nbsp  
\<%= radio\_button (‘attending\_ip’, :problem\_1\_status, ‘4’) %\>Resolved\</  
FONT\>

problem\_1\_status -\> char

thanks,

---

<div class="post-metadata">

**Author:** ![backz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9f8e36/32.png) [@backz](https://www.ruby-forum.com/u/backz)\
**Post date:** [January 23, 2008, 7:13pm UTC](https://www.ruby-forum.com/t/reading-oracle-data-type-char-in-radio-button/126949/2 "2008-01-23T19:13:52Z")

</div>

I used console to check what is being for a specific record and I  
found the problem. Somehow, it was returning empty space.

---

<div class="post-metadata">

**Author:** ![backz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/9f8e36/32.png) [@backz](https://www.ruby-forum.com/u/backz)\
**Post date:** [January 28, 2008, 9:36am UTC](https://www.ruby-forum.com/t/reading-oracle-data-type-char-in-radio-button/126949/3 "2008-01-28T09:36:05Z")

</div>

Hi kimda,  
The CHAR data type in Oracle specifies a fixed-length character string.  
If  
inserting a value that is shorter than the column length, Oracle will  
fill  
the value with blanks. If the length of the column is 2 and you insert  
‘1’,  
the string "1 " will be stored, so the radio button generated by “\<%=  
radio\_button (‘attending\_ip’, :problem\_1\_status, ‘1’) %\>” won’t be  
checked  
because ‘1’ does not equal to '1 '.

The VARCHAR data type doesn’t have this problem.

2008/1/24, kimda [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > buttons are unchecked). text\_field works fine for char data type. Is  
> > FONT\>
> > 
> > problem\_1\_status → char
> > 
> > thanks,

–  
Regards,  
Jesse
