Table without primary key


#1

Hi all.
I have table without in my DB.
Rails try to use non-existent sequence and try to write value into
non-existent primary key. And i have DB error.
How to use model with such table?
I try
set_sequence_name nil
set_primary_key nil
and
set_sequence_name “”
set_primary_key “”

  • not works.
    Help me please.
    Bye.

#2

Hi,

Why don’t you just add a primary key?
If you don’t have a primary key, how do you find entries in the
database?

Jens


#3

Why don’t you just add a primary key?

I can not modify DB. I did not create DB. I use it only.

If you don’t have a primary key, how do you find entries in the
database?
I use SQL :slight_smile:
You can create table without PK and you will be able to get data :slight_smile:


#4

Why don’t you just add a primary key?
I did not create DB. I can’t modify it, only use.
If you don’t have a primary key, how do you find entries in the database?
I use SQL :slight_smile:


#5

On Feb 13, 2007, at 7:18 AM, Step wrote:

Why don’t you just add a primary key?

I can not modify DB. I did not create DB. I use it only.

Since I don’t know the answer, I’ll ask Step’s question another way:
why not ask the DBA to add a primary key?

If you don’t have a primary key, how do you find entries in the
database?
I use SQL :slight_smile:
You can create table without PK and you will be able to get data :slight_smile:

Of course. I think what Step wanted to know was what criteria do you
use to find unique rows?

Craig


#6

Oops. In my earlier reply, I meant to reference Jens’ questions
instead of Step’s. I’m sorry for any confusion.

Craig


#7

Win with
set_primary_keys - tool for composite primary key

gem --install composite_primary_keys


#8

Did you or a DBA create a compound one instead of a simple one?
Or, did you have a compound one all along?
No.
Table had not any PK.
Table has not any PK now.
I tried use set_primary_key :column_name but it didn’t work. When i
tried to save row i had got error. I don’t know why.
I tried use this gem and use set_primary_keys :column_name - it
works.


#9

On Feb 13, 2007, at 9:29 AM, Step wrote:

Win with
set_primary_keys - tool for composite primary key

gem --install composite_primary_keys

I agree that this is a great gem, but you wrote that your table
didn’t have a primary key. Did you or a DBA create a compound one
instead of a simple one? Or, did you have a compound one all along?

Craig