Unable to insert data if no primary key, WHY?

Unable to insert data if no primary key, WHY?

Post by MR HO MING LEO » Wed, 08 Nov 1995 04:00:00



I am a new powerbuilder programmer and now encounter problem
which may be silly. Anyway, can anyone help to answer this.

My problem is that I have a table which contains two fields, x_axis and y_axis.
This table is used for a line chat so there should be no primary key.
However, I cannot insert any data into database if no primary key defined.
I want to know how can I insert data into a table which has no primary key.

I only use WATCOM as backend.
Thank for any suggestion...

Frankie

 
 
 

Unable to insert data if no primary key, WHY?

Post by Daniel Doyo » Wed, 08 Nov 1995 04:00:00



Quote:>I am a new powerbuilder programmer and now encounter problem
>which may be silly. Anyway, can anyone help to answer this.

>My problem is that I have a table which contains two fields, x_axis and y_axis.
>This table is used for a line chat so there should be no primary key.
>However, I cannot insert any data into database if no primary key defined.
>I want to know how can I insert data into a table which has no primary key.

>I only use WATCOM as backend.
>Thank for any suggestion...

>Frankie

Irregardless of your DB you will not be able to insert into your keyless
table. It seems that PB wants to make sure there are no duplicates in
tables and makes it difficult for you to do this.  One option is to put a
counter type key that increments for each add. You can create a new table
with a defined key in PB 4.0 using Data Pipelines. You may have to do
some SQL in order to generate all the keys. There may be a way of adding
data but I haven't see it. If you have Access 2.0 and the new ODBC
drivers (or VB Pro) you could do your data entry in Access and manipulate
the data through PB. It's probably easiest to just add the key in. Hope
this helps...

Dan
--
          Jupiter Five Technologies
Contact: Daniel Doyon     Phone: 617/623-6277

Specializing in Data Entry, Data Processing, CAD Drawing Conversion

 
 
 

Unable to insert data if no primary key, WHY?

Post by Vadim J. Nikit » Sat, 11 Nov 1995 04:00:00



: I am a new powerbuilder programmer and now encounter problem
: which may be silly. Anyway, can anyone help to answer this.

: My problem is that I have a table which contains two fields, x_axis and y_axis.
: This table is used for a line chat so there should be no primary key.
: However, I cannot insert any data into database if no primary key defined.
: I want to know how can I insert data into a table which has no primary key.

: I only use WATCOM as backend.
: Thank for any suggestion...

    You cannot insert data into that table from within database painter,
but you can go to "database administration" tool and write SQL INSERT's.
    In your datawindows you can insert data in tables without primary key.
To do it, you must simply define any field as primary key, or use ROWID, if
possible. Update's would be incorrect, but insert's ok.

 
 
 

Unable to insert data if no primary key, WHY?

Post by David N » Mon, 20 Nov 1995 04:00:00


Seems like you got many reasons why it can not be done.

The solution I would suggest is that insert a surrogate key for the
table.

David

 
 
 

1. accessing primary key slower than accessing non primary key???

hi,
I am using postgresql 7.1.3 under RH linux 7.2
For sake of comparison of speeds i am doing a small experiment.
I am having a table with 20 columns (1 col with bigint as primary key)
the size of a record is 300 bytes.
On retrieving records with select query with where clause accessing a
primary key and a non primary key the times are as follows

              time in ms per query retrieval
                py key   non py key
                ------   -----------
2000            15.8     15.7
10000           71.2     70.7
25000           174      173.5
100000          4319     3417

As u see the non primary key retrieval is faster. AFAIK accessing primary
key should be faster. Can anybody throw light on why is this anamoly.

I use libpq with blocking execution of queries.
I ran this test with there being no other load in the system.

TIA.

--------
regards,
hari
      __
     / /    __  _  _  _  _ __  __         -o)
    / /__  / / / \\// //_// \\ \\/ /         /\\\\  Making things happen
   /____/ /_/ /_/\\/ /___/  /_/\\_\\        _\\_v-  

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

2. CMM & Metrics

3. Getting back the primary key after INSERT

4. Outlook Express slow starting

5. Insert Row to ResultSet problem....java.sql.SQLException: No Primary Keys

6. How to remove an article?

7. Inserting spaces into a primary key column

8. There is a NES emulator in Japan!!

9. Insert : how to get the primary key

10. Why doesn't Powerbuilder see Sybase's Primary Key??

11. Why doesn't PowerBuilder pick up Sybase primary keys?

12. Database modeling: why is it an error for a table to not have a primary key??

13. Field in HTML form which is Primary Key of the Data Base table