甲骨文常用命令9(函数)
墨初 知识笔记 127阅读
Function: create [or replace] the function name [(param 1, param 2)] and return the executable file statement with the data type of | AS[ local declaration]; Return the result; Height : 150%; Margin: 0' class='MsoNormal' exception handler; End; Function call 1. As pl/sql
alibri; mso-ascii-theme-font: minor-latin; mso-fareast-font-family: 宋体; mso-fareast-theme-font: minor-fareast; mso-hansi-font-family: Calibri; mso-hansi-theme-font: minor-latin; mso-bidi-font-weight: bold">的一部分
begin
变量 := 函数名(参数列表)

End;
2、 作为sql语句的一部分
Select 函数名(参数列表) from dual;
例:根据订单编号 返回 订单总金额(根据订单明细中的商品价格、数量)
create or replace function getOrderMoney(v_id number)
return number
is
totalmoney number(7);
begin
select sum( D_QUANTITY * D_PRICE ) into totalmoney from orderDetail where O_ID = v_id;
return totalmoney;
end;
--测试函数:根据订单编号 返回 订单总金额
select getOrderMoney(1) from dual;
标签: