Create record into Oracle DB

A

Alexey Nik

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
 
J

Jesse Hu

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
 
A

Alexey Nik

Jesse said:
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,
)
 
J

Jesse Hu

[Note: parts of this message were removed to make it a legal post.]

2008/2/20 said:
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,
)
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?
 
A

Alexey Nik

Jesse said:
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
 
J

Jesse Hu

[Note: parts of this message were removed to make it a legal post.]

2008/2/21 said:
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
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.*
 
A

Alexey Nik

Jesse said:
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
}
 
J

Jesse Hu

[Note: parts of this message were removed to make it a legal post.]

2008/2/22 said:
Table structure in DB already exist, like this:
{
CLIENT_NAME VARCHAR2(35 BYTE) NOT NULL,
TREE_NAME VARCHAR2(35 BYTE) NOT NULL
}
You can ask for help from the rails-talk mailing list [
(e-mail address removed)].
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,284
Messages
2,571,411
Members
48,104
Latest member
Hellmary01

Latest Threads

Top