| Author |
Topic |
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2008-07-21 : 13:57:05
|
Want to set up a trigger that will only insert records into another table if the qty_bkord is not zero. Tables:oelinhst_sqlOrderRebateHistoryWhen records are inserted into the oelinhst if the qty_bkord is not zero then insert records into the OrderRebateHistory. This is what I have so far but I get a message"inserted.qty_bkord could not be bound."beginif inserted.qty_bkord <> 0 insert into OrderRebateHistory(ord_type,ord_no,line_seq_no,status,item_no,price,rebate_pct,qty_ordered,qty_to_ship,cus_no,AccountTypeCode,cd_tp,inv_no,freefield3,A4ID)selectinserted.ord_type,inserted.ord_no,inserted.line_seq_no,orderrebate.status,orderrebate.item_no,orderrebate.price,orderrebate.rebate_pct,inserted.qty_ordered,inserted.qty_to_ship,inserted.cus_no,orderrebate.AccountTypeCode,orderrebate.cd_tp,orderrebate.inv_no,orderrebate.freefield3,orderrebate.A4IDFROM inserted INNER JOIN oelinhst_sql ON inserted.ord_type = oelinhst_sql.user_def_fld_5 and inserted.item_no = oelinhst_sql.item_no AND inserted.ord_no = oelinhst_sql.ord_no AND inserted.inv_no = oelinhst_sql.inv_no join orderrebate on inserted.ord_type = orderrebate.ord_type andinserted.item_no = orderrebate.item_no and inserted.ord_no = orderrebate.ord_noend |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-07-21 : 14:00:28
|
you dont reuire if. just do like this:-insert into OrderRebateHistory(ord_type,ord_no,line_seq_no,status,item_no,price,rebate_pct,qty_ordered,qty_to_ship,cus_no,AccountTypeCode,cd_tp,inv_no,freefield3,A4ID)selectinserted.ord_type,inserted.ord_no,inserted.line_seq_no,orderrebate.status,orderrebate.item_no,orderrebate.price,orderrebate.rebate_pct,inserted.qty_ordered,inserted.qty_to_ship,inserted.cus_no,orderrebate.AccountTypeCode,orderrebate.cd_tp,orderrebate.inv_no,orderrebate.freefield3,orderrebate.A4IDFROM inserted INNER JOIN oelinhst_sql ON inserted.ord_type = oelinhst_sql.user_def_fld_5 and inserted.item_no = oelinhst_sql.item_no AND inserted.ord_no = oelinhst_sql.ord_no AND inserted.inv_no = oelinhst_sql.inv_no join orderrebate on inserted.ord_type = orderrebate.ord_type andinserted.item_no = orderrebate.item_no and inserted.ord_no = orderrebate.ord_noWHERE inserted.qty_bkord <>0 |
 |
|
|
|
|
|