使用 oracle 对 sql 语句进行编码,得到了一些我不完全理解/难以掌握的作业(因此,如果您有任何关于基本 sql 过程/功能的好的教程/链接,将不胜感激。
这是问题
一种存储过程,其中列出了 La Trobe 电子拍卖数据库系统中所有物品的名称、描述和价值,以及一列显示:如果拍卖已经结束,则显示“已售出”,如果拍卖已售出,则显示“无出价”如果拍卖已经结束但未达到保留价,则已关闭且未对“无销售”项目进行投标
如果该物品的拍卖仍在进行中,则为“拍卖中”
Item (itemNumber, itemName, itemDescription, itemValue, itemLocation,
categoryID, sellerUsername)
Auction (auctionNumber, currency, startDateTime, endDateTime, shippingTerms,
startBidAmount, reserveAmount, bidIncrementAmount, noOfItems, itemSold,
itemNumber feedbackDateAndTime, rating, comments, paymentDate, paymentid)
Bid (bidderUsername, auctionNumber, bidDateTime,bidAmount)
这是我制定的理论,但我不知道如何编码。
status column - a)sold, closed and item is sold
b)no bid, auction is close and no bids
c)no sale, the auction is closed but reserve wasnt met
d)on auction, auction for the item is still open
a) if i.itemnumber=a.itemnumber and itemSold='y'
b) if a.auctionnumber != b.auctionnumber and systemdate>endDateTime
c) if sysdate>endDatetime and a.auctionnumber=b.auctionnumber
and reserveamount>select b.bidAmount
from bid where a.auctionnumber=b.auctionnumber
and b.bidAmount.max;
d) if itemSold ='n' and sysdate<endDateTime;
CREATE OR REPLACE PROCEDURE allItemStatus
AS
p_itemName Item.itemName%TYPE;
p_itemDescription Item.itemDescription%TYPE;
p_itemValue Item.itemValue%TYPE;
P_itemSold Auction.itemSold%TYPE;
BEGIN
SELECT i.itemName, i.itemDescription, i.itemValue, a.itemSold
INTO p_itemName, p_itemDescription, p_itemValue , p_itemSold
FROM dbf12.Item i, dbf12.Auction a
WHERE i.itemNumber=a.itemNumber
AND a.itemSold='Y';
DBMS_OUTPUT.PUT_LINE('Item Name: '||p_itemName);
DBMS_OUTPUT.PUT_LINE('Item Description: '||p_itemDescription);
DBMS_OUTPUT.PUT_LINE('Item Value: '||p_itemValue);
DBMS_OUTPUT.PUT_LINE('Item Sold: '||p_itemSold);
END allItemStatus;
任何帮助将不胜感激。我知道我几乎没有写出整件事,但我不知道该去哪里。
这是我当前的代码,它不喜欢我的 sysdate>a.enddattime
SELECT
i.itemname,
i.itemdescription,
i.itemvalue,
CASE
WHEN i.itemnumber=a.itemnumber and a.itemSold='y' THEN 'Sold'
WHEN a.auctionnumber != b.auctionnumber and systemdate>endDateTime THEN 'No Bids on that closed auction'
WHEN TO_CHAR(sysdate,'DD-MON-YY')<a.endDatetime and a.auctionnumber=b.auctionnumber
and reserveamount>(
SELECT b.bidAmount
WHERE a.auctionnumber=b.auctionnumber
AND b.bidAmount.max) THEN 'No Bids that meets the reserve'
ELSE 'Auction Still Open'
END
FROM
dbf12.item i, dbf12.auction a, dbf12.bid b;