0

我希望该项目的 item.cost 将是 product.price * product.quantity..

当我表项时我该怎么做?

有我的 SQL 代码:

create or replace type Product as Object(
product_code char(6);
product_name varchar2(6);
description clot(500);
price number(6,2);
constraint uniq_product_code primary key(product_code)
);
/

CREATE TYPE Products IS TABLE OF Product;

CREATE or replace type object Item  as Object(
item_code char(6);
quantity number(6);
cost number(11,2);
products Product;
constraint uniq_item_code primary key(item_code)
);
NESTED TABLE products STORE AS item_product;
/

Create  type Items is Table of Item;

CREATE or replace TYPE Contact_detail AS OBJECT (
   email    varchar2(30);
   address  VARCHAR2(50);
   telephone   varchar2(20);
);
/

Create or replace table Order(
order_number char(6);
order_name varchar2(6);
customer_contact_details Contact_detail;
date date;----
Items Item;
constraint uniq_order_number primary key(order_number)
);
NESTED TABLE Items STORE AS order_item;
/

此外,我将制作一个 PL/SQL 以允许用户输入来自用户的信息以插入到 Order 表中。如何自动检测物品的数量。数量 n, 2<=n<=10。

4

1 回答 1

0

将成员函数添加到 Item 对象类型以计算值。

于 2013-01-13T04:23:51.253 回答