CREATE OR REPLACE FUNCTION money_of_order1 (p_sit_where IN NUMBER) RETURN NUMBER IS total_money NUMBER := 0; BEGIN FOR row IN (SELECT food_number, food_price_initial FROM view_oder WHERE sit_where = p_sit_where) LOOP total_money := (row.food_number * row.food_price_initial) + total_money; END LOOP; RETURN total_money; END; / CREATE OR REPLACE procedure s_money(sit_where in number) is sit_number NUMBER := 1; money NUMBER := 0; BEGIN FOR row IN (SELECT sit_where FROM view_oder WHERE sit_where = sit_number) LOOP money := money_of_order1(row.sit_where); UPDATE m_oder SET oder_money = money WHERE sit_where = row.sit_where; sit_number := sit_number + 1; END LOOP; END; / declare begin for row in (select sit_where from m_oder) loop s_money(row.sit_where); end loop; end; /
时间: 2024-03-11 19:46:21 浏览: 57
sql.rar_Money_ Money_ Money
这段代码是什么意思?
这段代码是一个 Oracle 数据库中的存储过程和函数,用于计算餐厅点餐的总金额。其中,函数 money_of_order1 用于计算某个桌位点餐的总金额,而存储过程 s_money 则用于遍历所有桌位并更新订单表中对应桌位的总金额。最后的 declare begin/end 则是用于调用 s_money 存储过程的代码。
阅读全文