Hey guys, i am new to oracle and sql, i am doing a project for my bsc in IT and i have to develop a online computer store, everything was going great but now i am trying to do the order processing and i can't get this code to run, a friend gave it to me and told me that it should be used as a page processing process. any advice would be greatly appreciated

declare
l_ordernumber number;
l_usernumber number;
l_total number;

insert into invoicedetails
values (1,:P27_invoiceid,rec.productid,rec.productquantity,rec.sellingprice);

begin

select userid into l_usernumber from users where upper(username) = upper(:APP_USER);
select invoicedetails_seq.nextval into l_ordernumber from dual;
select sum(price) into l_total from cart where userid = l_usernumber;

insert into invoice values(l_ordernumber, sysdate, l_total,l_usernumber,11,11);
commit;

for rec in (select PRODUCTID, USERID, SUM(PRICE) AS PRICE, SUM(QUANTITY) AS QUANTITY
FROM CART WHERE USERID = l_usernumber
group by userid, productid)
loop
insert into invoicedetails values
(1, l_ordernumber, rec.productid, rec.price, rec.quantity);
end loop;