# Create record into Oracle DB

**URL:** <https://www.ruby-forum.com/t/create-record-into-oracle-db/129457>\
**Category:** Ruby\
**Created:** [February 18, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457 "2008-02-18T20:08:44Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sad](https://www.ruby-forum.com/u/sad)\
**Post date:** [February 18, 2008, 8:08pm UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457/1 "2008-02-18T20:08:44Z")

</div>

Hello all, there is part of my code :  
folder = Folder1.new()  
folder.ID = @id  
folder.CLIENT\_NAME = @un  
folder.TREE\_NAME = @tn  
folder.save()  
when i test it on mySql all work right, but when i try it with Oracle i  
got this error #NoMethodError (undefined method `ID=’ for  
#FolderTree:0x4bae7cc).

I try again with other ruby method  
Folder1.create(:ID =\> @id, :CLIENT\_NAME =\> @un, :TREE\_NAME =\> @tn)

and again got error : #NoMethodError (undefined method `CLIENT\_NAME=’  
for #FolderTree:0x4baf6a4)

Other actions (e.g. Folder1.find(:all,:conditions =\> “ID  
=’”+Id.to\_s+"’")) works good.

Smb know why Oracle return error #NoMethodError

---

<div class="post-metadata">

**Author:** ![sad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sad](https://www.ruby-forum.com/u/sad)\
**Post date:** [February 20, 2008, 4:40am UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457/2 "2008-02-20T04:40:35Z")

</div>

why u use upper case name as the field name?  
Please use lower case and try again:  
folder = Folder.new()  
folder.id= @id  
folder.client\_name = @un  
folder.tree\_name = @tn  
folder.save()

- 

Cheers,  
Jesse

---

<div class="post-metadata">

**Author:** ![sad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sad](https://www.ruby-forum.com/u/sad)\
**Post date:** [February 20, 2008, 9:30am UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457/3 "2008-02-20T09:30:08Z")

</div>

Jesse Hu wrote:

> why u use upper case name as the field name?  
> Please use lower case and try again:  
> folder = Folder.new()  
> folder.id= @id  
> folder.client\_name = @un  
> folder.tree\_name = @tn  
> folder.save()
> 
> - 
> 
> Cheers,  
> Jesse

## I use upper case, because fields names in db have upper case ( ID INTEGER, CLIENT\_NAME VARCHAR2(35 BYTE) NOT NULL, TREE\_NAME VARCHAR2(35 BYTE) NOT NULL, )

## I try lower case and got error : undefined method `id=’ for #FolderTree:0x54060b0

Does anybody have solution of this problem ?

---

<div class="post-metadata">

**Author:** ![sad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sad](https://www.ruby-forum.com/u/sad)\
**Post date:** [February 21, 2008, 3:26am UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457/4 "2008-02-21T03:26:44Z")

</div>

2008/2/20, Alexey N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > -
> 
> ## I try lower case and got error : undefined method `id=’ for #FolderTree:0x54060b0
> 
> ## Does anybody have solution of this problem ?
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

It has no relation to the character case of field names in db. You’d  
better  
use lower case string for the function name in Ruby.

How is your db migration file (001\_create\_fold\_trees.rb  
) for the FoldTree model like?

---

<div class="post-metadata">

**Author:** ![sad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sad](https://www.ruby-forum.com/u/sad)\
**Post date:** [February 21, 2008, 11:56am UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457/5 "2008-02-21T11:56:20Z")

</div>

Jesse Hu wrote:

> 2008/2/20, Alexey N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > > -
> > 
> > ## I try lower case and got error : undefined method `id=’ for #FolderTree:0x54060b0
> > 
> > ## Does anybody have solution of this problem ?
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> It has no relation to the character case of field names in db. You’d  
> better  
> use lower case string for the function name in Ruby.
> 
> How is your db migration file (001\_create\_fold\_trees.rb  
> ) for the FoldTree model like?

it’s conetns of 001\_create\_folder\_trees.rb :  
class CreateFolderTrees \< ActiveRecord::Migration  
def self.up  
create\_table :folder\_trees do |t|  
end  
end

def self.down  
drop\_table :folder\_trees  
end  
end

---

<div class="post-metadata">

**Author:** ![sad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sad](https://www.ruby-forum.com/u/sad)\
**Post date:** [February 22, 2008, 9:45am UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457/6 "2008-02-22T09:45:40Z")

</div>

Jesse Hu wrote:

> 2008/2/21, Alexey N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
> 
> > > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).  
> > > > class CreateFolderTrees \< ActiveRecord::Migration  
> > > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> That’s the problem. You need to define columns for the folder\_trees  
> table  
> like this:
> 
> _def self.up  
> create\_table :folder\_trees do |t|_
> 
> - 
> 
> ```
> t.column :client_name, :string*
> 
> ```
> 
> - 
> 
> ```
> t.column :tree_name, :string
> 
> ```
> 
> end  
> end\*  
> \*\*
> 
> _Then run rake task “rake db:migrate” to create the table in db._

Table structure in DB already exist, like this:  
{  
CLIENT\_NAME VARCHAR2(35 BYTE) NOT NULL,  
TREE\_NAME VARCHAR2(35 BYTE) NOT NULL  
}

---

<div class="post-metadata">

**Author:** ![sad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sad](https://www.ruby-forum.com/u/sad)\
**Post date:** [February 22, 2008, 10:35am UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457/7 "2008-02-22T10:35:02Z")

</div>

2008/2/22, Alexey N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > like this:
> 
> Table structure in DB already exist, like this:  
> {  
> CLIENT\_NAME VARCHAR2(35 BYTE) NOT NULL,  
> TREE\_NAME VARCHAR2(35 BYTE) NOT NULL  
> }
> 
> –  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

You can ask for help from the rails-talk mailing list [  
removed\_email\_address@domain.invalid].

---

<div class="post-metadata">

**Author:** ![sad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/8797f3/32.png) [@sad](https://www.ruby-forum.com/u/sad)\
**Post date:** [February 22, 2008, 2:44am UTC](https://www.ruby-forum.com/t/create-record-into-oracle-db/129457/8 "2008-02-22T02:44:57Z")

</div>

2008/2/21, Alexey N. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).  
> > > class CreateFolderTrees \< ActiveRecord::Migration  
> > > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

That’s the problem. You need to define columns for the folder\_trees  
table  
like this:

_def self.up  
create\_table :folder\_trees do |t|_

- 

```
   t.column :client_name, :string*

```

- 

```
   t.column :tree_name, :string

```

end  
end\*  
\*\*

_Then run rake task “rake db:migrate” to create the table in db._
