i have three tables. name of the tables: PRODUCT,ORDER_HEADER,ORDER_DETAIL. i have taken INTER-ACTIVE REPORT in which VALUES are coming from TABLE Product . i need to use trigger here there is one TEXT ITEM called ORDER ID: it will generate via trigger. so each time new order placed order id must be unique. there is one button on click of that button REPORT VALUES must be inserted in to ORDER_HEADER,ORDER_DETAIL(Actually i am in confusion is it even possible).
I tried to create Trigger: Not Working Though
CREATE OR REPLACE TRIGGER "EMP_TRG1"
before insert on order_header
for each row
begin
if :new.Order_ID is null
then
select lpad(demo_seq.nextval,8,'0') into :new.Order_ID from order_header;
end if;
end;
SQL:
select
apex_item.text(1,p.PRODUCT_ID) PID,
pn.product_name,
apex_item.text(2,p.PRODUCT_QTY) qt,
apex_item.text(3,p.unit_price) up,
apex_item.text(4,p.TOTAL_AMOUNT) am
from OMS_SHIP_CART_DETAIL p, OMS_PRODUCT pn
where p.product_id=pn.product_id
DA:
var arr_f01 = [];
var arr_f02 = [];
var arr_f03 = [];
var arr_f04 = [];
var arr_f05 = [];
var product_id;
var unit_price;
var qty;
var total_1;
$("input[name='f01']").each(
function() {
product_id = $(this).closest('tr').children('td[headers="PID"]').text() ;
unit_price = $(this).closest('tr').children('td[headers="Uprice"]').text() ;
qty = $(this).closest('tr').children('td[headers="Qty"]').text() ;
total_1=$(this).closest('tr').children('td[headers="total"]').text() ;
arr_f01.push($(this).val());
arr_f02.push(product_id);
arr_f03.push(total_1);
arr_f04.push(unit_price);
arr_f05.push(qty);
} );
apex.server.process (
"insert order"
, { f01: arr_f01, f02: arr_f02, f03: arr_f03, f04: arr_f04, f05: arr_f05
}
, { dataType: 'text',success: function(pData){alert('Product Added'); }
);
Ajax CallBack:
declare
l_count number;
begin
--insert into OMS_ORDER_HEADER(USER_ID,TOTAL_AMOUNT,STATUS_ID,ORDER_DATE)values(:P1_USER_ID,:P42_TOTAL,'PENDING',SYSDATE);
for i in 1..apex_application.g_f01.count loop
insert into OMS_ORDER_DETAIL(PRODUCT_ID,UNIT_QTY,UNIT_PRICE,TOTAL_AMOUNT)
values(APEX_APPLICATION.G_F01(i),APEX_APPLICATION.G_F03(i),APEX_APPLICATION.G_F04(i),APEX_APPLICATION.G_F05(i));
commit;
end loop;
end;