sp_medicinestockfindamount.sql

来自「一整套的源代码」· SQL 代码 · 共 31 行

SQL
31
字号

create or replace function sp_medicinestockfindamount(l_medicinestockid in integer)
  return number is
  l_medicinestockdetailid integer;
  l_count                 integer;
  l_amount                number(16,
                                 4);
begin
  select count(*)
  into   l_count
  from   medicinestockdetail
  where  medicinestockid = l_medicinestockid and amount > 0;

  if l_count = 0 then
    return - 1;
  end if;

  select min(medicinestockdetailid)
  into   l_medicinestockdetailid
  from   medicinestockdetail
  where  medicinestockid = l_medicinestockid and amount > 0;

  select amount
  into   l_amount
  from   medicinestockdetail
  where  medicinestockdetailid = l_medicinestockdetailid;

  return l_amount;
end;
/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?