Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Create record into Oracle DB

Reply
Thread Tools

Create record into Oracle DB

 
 
Alexey Nik
Guest
Posts: n/a
 
      02-18-2008
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
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Jesse Hu
Guest
Posts: n/a
 
      02-20-2008
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

On Feb 19, 3:08*am, Alexey Nik <sc_...@tut.by> wrote:
> 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
> --
> Posted viahttp://www.ruby-forum.com/.


 
Reply With Quote
 
 
 
 
Alexey Nik
Guest
Posts: n/a
 
      02-20-2008
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 ?
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Jesse Hu
Guest
Posts: n/a
 
      02-21-2008
[Note: parts of this message were removed to make it a legal post.]

2008/2/20, Alexey Nik <>:
>
> 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 ?
> --
> Posted via 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?

--
Cheers,
Jesse

 
Reply With Quote
 
Alexey Nik
Guest
Posts: n/a
 
      02-21-2008
Jesse Hu wrote:
> 2008/2/20, Alexey Nik <>:
>> > -

>> 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/.
>>
>>

> 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
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Jesse Hu
Guest
Posts: n/a
 
      02-22-2008
[Note: parts of this message were removed to make it a legal post.]

2008/2/21, Alexey Nik <>:
>
> Jesse Hu wrote:
> > 2008/2/20, Alexey Nik <>:
> >> > -
> >> 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/.
> >>
> >>

> > 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
> --
> Posted via 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.*

--
Cheers,
Jesse

 
Reply With Quote
 
Alexey Nik
Guest
Posts: n/a
 
      02-22-2008
Jesse Hu wrote:
> 2008/2/21, Alexey Nik <>:
>> >> Posted via http://www.ruby-forum.com/.

>> class CreateFolderTrees < ActiveRecord::Migration
>> Posted via 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
}

--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Jesse Hu
Guest
Posts: n/a
 
      02-22-2008
[Note: parts of this message were removed to make it a legal post.]

2008/2/22, Alexey Nik <>:
>
> Jesse Hu wrote:
> > 2008/2/21, Alexey Nik <>:
> >> >> Posted via http://www.ruby-forum.com/.
> >> class CreateFolderTrees < ActiveRecord::Migration
> >> Posted via 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
> }
>
> --
> Posted via http://www.ruby-forum.com/.
>
>

You can ask for help from the rails-talk mailing list [
rubyonrails-].

--
Cheers,
Jesse

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IP Address, MX Record, A Record Question K.J. 44 Cisco 2 09-06-2006 05:14 PM
You cannot add or change a record because a related record is required in table 'lok" André ASP .Net 0 06-25-2006 01:30 PM
install_driver(Oracle) failed: Can't load 'C:/Perl/site/lib/auto/DBD/Oracle/Oracle.dll' for module DBD::Oracle: load_file:The specified procedure could not be found at C:/Perl/lib/DynaLoader.pm line 230. Feyruz Perl Misc 4 10-14-2005 06:47 PM
Retrieving Record Key while creating the record. =?Utf-8?B?SnVzdGlu?= ASP .Net 4 10-05-2004 08:11 PM
" Invalid Disk Table in Boot Record - Boot Record could not be repaired " reply@newsgroup.please Computer Support 2 12-01-2003 05:37 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57