我想执行多个选择查询以及 for 和 if 循环。
表:A:Orderno、ContractNo
B: ContractNo, ItemNo, Price, TotalAmount
C: OrderNo, ITemNo, 数量
一份合约可以有多个订单(合约和订单是一对多的关系)。我只有 ItemNo 和 ContractNo 作为输入。
下面是我的伪代码。
Find the total amount for the item no from table B.
List the orders for the same contract.
Foreach(orderno in orders)
List items in orderno
if(itemno matches 1)
get the quantity (which is equal to totalamount/price)
End
Print quantity
我是 Oracle 的新手,我想这可以通过存储过程来完成,但我不确定它是否可以满足伪代码的要求。任何人都可以建议或告诉我什么可以用来执行这段代码吗?