•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Oracle section within the Web Development category of DaniWeb, a massive community of 361,943 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,690 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Oracle advertiser:
Views: 450 | Replies: 9
![]() |
•
•
Join Date: Mar 2008
Posts: 5
Reputation:
Rep Power: 0
Solved Threads: 0
Hi,
I have some tables (below), but I'm having trouble entering multiple lines of data.
Here are the tables I have created.
I can enter data into the customer, salesman and item table without any problems. However, I need to enter multiple lines of data using the same invoice_no (which is 1). The data is generally the same, except for 2 things need changing but I keep getting the following error...
I understand that I can only use invoice_no once since it is a unique key.
Is there a way of getting around this problem?
Any solution or advice would be greatly appreciated. Thank you!
I am also fairly new to database systems.
I have some tables (below), but I'm having trouble entering multiple lines of data.
Here are the tables I have created.
•
•
•
•
CUSTOMER table
SQL> create table customer
2 (customer_no char(6) not null,
3 name varchar2(30) not null,
4 address varchar2(50) not null,
5 credit_limit number(6,2),
6 constraint customer_customer_no_pk primary key (customer_no));
Table created.
SALESMAN table
SQL> create table salesman
2 (salesman_id char(8),
3 name varchar2(20) not null,
4 address varchar2(50) not null,
5 emaill_address varchar2(30),
6 constraint salesman_salesman_id_pk primary key (salesman_id));
Table created.
ITEM table
SQL> create table item
2 (ISBN char(13) not null,
3 title varchar2(30) not null,
4 price number(4,2) not null,
5 constraint item_ISBN_pk primary key (ISBN));
Table created.
INVOICE table
SQL> create table invoice
2 (invoice_no char(1) not null,
3 invoice_date date not null,
4 salesman_id char(8),
5 customer_no char(6) not null,
6 ISBN char(13) not null,
7 Nos varchar2(2) not null,
8 credit_limit number(6,2),
9 payment_type varchar2(6) not null,
10 constraint invoice_invoice_no_pk primary key (invoice_no),
11 constraint invoice_salesman_id_fk foreign key (salesman_id)
12 references salesman(salesman_id),
13 constraint invoice_customer_no_fk foreign key (customer_no)
14 references customer(customer_no),
15 constraint invoice_ISBN_fk foreign key (ISBN)
16 references item(ISBN));
Table created.
DELIVERY table
SQL> create table delivery
2 (invoice_no char(1) not null,
3 ISBN char(13) not null,
4 constraint delivery_invoice_no_ISBN_cpk primary key (invoice_no,ISBN),
5 constraint delivery_invoice_fk foreign key (invoice_no)
6 references invoice(invoice_no),
7 constraint delivery_ISBN_fk foreign key (ISBN)
8 references item(ISBN));
Table created.
I can enter data into the customer, salesman and item table without any problems. However, I need to enter multiple lines of data using the same invoice_no (which is 1). The data is generally the same, except for 2 things need changing but I keep getting the following error...
•
•
•
•
ORA-00001: unique constraint (SYSTEM.INVOICE_INVOICE_NO_PK) violated
I understand that I can only use invoice_no once since it is a unique key.
Is there a way of getting around this problem?
Any solution or advice would be greatly appreciated. Thank you!
I am also fairly new to database systems.
Last edited by Trogan : Apr 8th, 2008 at 2:25 pm.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,576
Reputation:
Rep Power: 18
Solved Threads: 184
So you've made a serious error in your datamodel.
Apparently a record in the invoice table does not represent an invoice but a line item.
Redesign your database to match that, with a new invoice table containing only items that are not repeated (like the invoice number), and a lineitem table containing a foreign key into to the invoice table to the invoice number.
Apparently a record in the invoice table does not represent an invoice but a line item.
Redesign your database to match that, with a new invoice table containing only items that are not repeated (like the invoice number), and a lineitem table containing a foreign key into to the invoice table to the invoice number.
42 Private messages asking for help will be ignored
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
In the frozen land of Nador they were forced to eat Steve's iMinstrels, and there was much rejoicing.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,576
Reputation:
Rep Power: 18
Solved Threads: 184
Hey good that you made your stuff work. But keep in mind this thing - The databases are only the repositoires of data. It is you who will have to decide what data goes in where and make sure that you use the capabilities of the database to reflect the exact needs of your data model (your data). Making ad-hoc changes might work bu they may not be fruitful in the long run. Also, analyse the model before you even try to create any tables in the database. That will definitely help in the long run.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Oracle Marketplace
Similar Threads
- What's the HARDEST program you've written? (Computer Science and Software Design)
- Manipulate Excel file using C++?? (C++)
- Best way to develop db for survey? (Database Design)
- Field Constraint (don't want negative numbers) (MS SQL)
- help please programme to build (Database Design)
- Need direction on how start this program (C++)
- Need direction on how start this programm (C++)
- Help With An Online Game! (Web Development Job Offers)
- Help With An Online Game! (Java)
Other Threads in the Oracle Forum
- Previous Thread: SYNONYMS
- Next Thread: Trigger help




Linear Mode