私はまだ SQL に不慣れで、学習段階にあります。かなり長い間取り組んできた宿題があり、シーケンス内のどこにエラーがあるのか わかりません。私はOracle SQLを使用しています。
INSERT INTO ORDERS
VALUES (SEQ_ORDER_ID.NEXTVAL, '200', 'MOVIE FOR RENT', '30', '322.61', '15.36', 'CP', '10-MAR-13', '15-MAR-13');
INSERT INTO ORDERS
VALUES (SEQ_ORDER_ID.NEXTVAL, '200', 'MOVIE FOR RENT', '30', '419.74', '19.99', 'CP', '12-MAR-13', '17-MAR-13');
INSERT INTO ORDER_ITEMS
VALUES (SEQ_ITEM_ID.NEXTVAL, SEQ_ORDER_ID.CURRVAL, '40', '10', '25', '12.29', '307.25');
INSERT INTO ORDER_ITEMS
VALUES (SEQ_ITEM_ID.NEXTVAL, SEQ_ORDER_ID.CURRVAL, '40', '11', '25', '15.99', '399.75');
Order_id と Item_id NEXTVAL と CURRVAL を並べたいと思います。私が得ているエラーは次のとおりです。
VALUES (SEQ_ITEM_ID.NEXTVAL, SEQ_ORDER_ID.CURRVAL, '40', '10', '25', '12.29', '307.25')
*
ERROR at line 2:
ORA-02289: sequence does not exist
VALUES (SEQ_ITEM_ID.NEXTVAL, SEQ_ORDER_ID.CURRVAL, '40', '11', '25', '15.99', '399.75')
*
ERROR at line 2:
ORA-02289: sequence does not exist
ご協力いただきありがとうございます。
ここにもう少し情報があります...
create table orders(
order_id number(8),
Store_id number(4) not null,
description varchar2(30),
total_items number(3),
total_payment number(8,2),
tax number(6,2),
order_status varchar2(2),
ordering_date date,
order_completed_date date
);
create table order_items(
item_id number(10),
order_id number(8) not null,
distribution_id number(8) not null,
movie_id number(5) not null,
number_of_items number(3),
item_unit_price number(5,2),
item_sub_total number(10,2)
);
alter table orders
add constraint order_pk primary key (order_id);
alter table orders
add constraint store_order_fk foreign key (store_id) references movie_rental_stores(store_id);
alter table order_items
add constraint order_item_pk primary key (item_id);
alter table order_items
add constraint order_item_fk foreign key (order_id) references orders(order_id);
alter table order_items
add constraint movie_item_fk foreign key (movie_id) references movies(movie_id);
alter table order_items
add constraint distributor_order_item_fk foreign key (distribution_id) references distributed_movie_list(distribution_id);
DROP sequence seq_order_id;
CREATE sequence seq_order_id
increment BY 1 START WITH 1 minvalue 1;
DROP sequence seq_order_item_id;
CREATE sequence seq_order_item_id
increment BY 1 START WITH 1 minvalue 1;