-1
create or replace procedure placeorder(
  itemid in tempcart.item_id%type,num in integer,cid in customer_info.cust_id%type)
is
  cnt integer;
  amt integer;
  next_id number(5);
  temp tempcart%rowtype;
  cursor temp2 is select * from tempcart where tempcart.item_id=itemid;
  cursor temp1 is select * from tempcart;
BEGIN
  cnt:=0;
  select count(*) into cnt from porder;
  select max(oid) into next_id from porder;
  if(cnt=0) then
    next_id:=1;
  else
    next_id:=next_id+1;
  end if;
  if(num=1) then
    insert into corder values(next_id,itemid);
    select amount into amt from tempcart where item_id=itemid;
    insert into porder values(next_id,amt,sysdate); 
    open temp2;
    fetch temp2 into temp;
    insert into history values (itemid,temp.pid,temp.quantity,temp.amount,cid,temp.name);
  else
    amt:=0;
    open temp1;
    loop
      fetch temp1 into temp;
      exit when temp1%notfound;
      insert into corder values(next_id,temp.item_id);
      amt:=amt+temp.amount;
      insert into history values(temp.item_id,temp.pid,temp.quantity,temp.amount,cid,temp.name);
    end loop;
    insert into porder values(next_id,amt,sysdate);      
  end if;
end placeorder;

この手順の何が問題になっていますか? それを使用して呼び出すと、placeorder(1,1,2)値は挿入されますが、では挿入されcorderませんporder

4

1 に答える 1