【正文】
。/*剛文杰*/create procedure clothsum classNo char(1)asbeginselect count(clothNo) 該服裝類別中服裝總數(shù)from cloth where classNo=classNoendgoexecute clothsum classNo=39。(5)設(shè)置帶參數(shù)的存儲(chǔ)過(guò)程,統(tǒng)計(jì)某服裝類別中服裝總數(shù)。exec cloth_name 39。/*剛文杰*/create procedure cloth_name name varchar(20),asselect * from clothwhere cloth_fname+cloth_lname like 39。cur_clothNodeallocateintoclothNofetchselectintocur_clothNofetchbyby=classNo=bOrderDetailclothNo,count(*)topcursorchar(50)declareintdeclareclothNochar(1))chunchu/*(涂星)*/create201239。E39。039。0039。%39。C39。/*(楊園)*/create procedure p_rentsumas begin declare orderno char(15) declare cur_rentsum scroll cursor for select orderNo from orderdetail open cur_rentsum fetch next from cur_rentsum into orderno while(fetch_status=0) begin update order set rentsum=* from orderdetail a where =orderno fetch next from cur_rentsum into orderno end close cur_rentsum deallocate cur_rentsum end(2)建立一個(gè)存儲(chǔ)過(guò)程,實(shí)現(xiàn)會(huì)員編號(hào)的自動(dòng)生成。如無(wú)特殊說(shuō)明,所有涉及到前臺(tái)服務(wù)請(qǐng)求的過(guò)程均封裝成后臺(tái)服務(wù)器的存儲(chǔ)過(guò)程,具體設(shè)計(jì)細(xì)節(jié),參見(jiàn)數(shù)據(jù)庫(kù)設(shè)計(jì)腳本。),OrderNo Char(15) not null, /*訂單編號(hào)*/sendDate Datetime not null, /*配送日期*/reciver Varchar(20) not null, /*收貨人*/sendAddress Varchar(40) not null, /*配送地址*/zipCode Char(6) not null, /*郵編*/sendTel Char(11) not null, /*電話*/sendState Char(6) not null, /*配送狀態(tài)*/constraint SendPK primary key (sendNo),constraint sendFK1 foreign key(orderNo) references orderMaster(orderNo))Go 數(shù)據(jù)庫(kù)完整性設(shè)計(jì)創(chuàng)建觸發(fā)器,如果服裝表中服裝改變時(shí),訂單明細(xì)表也隨之更改。), cusNo char(9) not null, /*會(huì)員編號(hào)*/ evaDate Datetime not null, /*評(píng)價(jià)日期*/ evaContent Varchar(280) not null, /*評(píng)價(jià)內(nèi)容*/ managerNo char(10) not null, /*管理員編號(hào)*/replyDate Datetime not null, /*回復(fù)日期*/replyContent Varchar(280) not null, /*回復(fù)內(nèi)容*/ constraint EvaluatePK primary key (evaNo))goCREATE TABLE Send 配送表( sendNo Char(8) not null, /*配送單號(hào)*/ check(sendNo like 39。), code char(12) not null, /*密碼*/ managerName varchar(20) not null, /*管理員姓名*/ sex char(2) not null, /*性別*/ birthday datetime not null, /*出生年月*/ salary numeric(7,2) not null, /*薪水*/address varchar(100) not null, /*地址*/telephone char(11) not null, /*電話號(hào)碼*/ char(40) not null, /*郵箱*/ constraint managerPK primary key (managerNo))GoCREATE TABLE Evaluate 評(píng)價(jià)表( evaNo char(7) not null, /*評(píng)價(jià)編號(hào)*/ check(evaNo like 39。), quantity numeric(7,2) not null, /*數(shù)量*/ price numeric(7,2) not null, /*價(jià)格*/color char() not null /*顏色*/size char(2) not null /*大小*/ constraint orderDetailPK primary key clustered(orderNo,clothNo), constraint orderDetailFK1 foreign key(orderNo) references ordermaster(orderNo), constraint orderDetailFK2 foreign key(clothNo ) references cloth(clothNo ) )Gocreate table manager 管理員表( managerNo char(10) not null, /*管理員編號(hào)*/ check(managerNo like 39。),clothName Varchar(50) not null, /*服裝名稱*/ price numeric(7,2) not null, /*價(jià)格*/ classNo char(1) not null, /*服裝類別編號(hào)*/ color char(6) not null, /*顏色*/ size char(2) not null, /*大小*/ quantity numeric(7,2) not null, /*數(shù)量*/ rent numeric(7,2) not null, /*租金*/ constraint clothPK primary key (clothNo), constraint clothFK1 foreign key(classNo) references class(classNo))gocreate table orderDetail 訂單明細(xì)表( orderNo char(15) not null , /*訂單編號(hào)*/ clothNo Char(12) not null, /*服裝編號(hào)*/check(clothNo like 39。), cusNo Char(8) not null, /*會(huì)員編號(hào)*/orderDate Datetime not null, /*訂單生成日期*/payWay Char(8) not null, /*支付方式*/payState Char(2) not null, /*支付狀態(tài)*/orderState Char(6) not null, /*訂單狀態(tài)*/shouldRecive numeric(5,2) not null, /*應(yīng)收租金額*/factRecive numeric(5,2) not null, /*實(shí)收租金額*/ constraint ordermasterPK primary key (orderNo),constraint ordermasterFK1 foreign key(cusNo) references customer(cusNo) )Gocreate table cloth 服裝表( clothNo char(12) not null , /*服裝編號(hào)*/ check(clothNo like 39。), className varchar(20) not null, /*服裝類別名稱*/ constraint classPK primary key (classNo) )Gocreate table ordermaster 訂單主表( orderNo char(15) not null , /*訂單編號(hào)*/check (orderNo like 39。), cusName varchar(20) not null, /*會(huì)員姓名*/code Char(12) not null, /*密碼*/rthday Datetime not null, /*出生年月*/sex char(2) not null, /*性別*/address varchar(100) not null, /*地址*/ telephone char(11) not null, /*電話*/ char(40) not nu