diff --git a/AstuteSystem/sql/astute.sql b/AstuteSystem/sql/astute.sql index 794abda..a30be7b 100644 --- a/AstuteSystem/sql/astute.sql +++ b/AstuteSystem/sql/astute.sql @@ -89,7 +89,7 @@ DECLARE detailCount int; SELECT COUNT(line_item_num) INTO detailCount FROM invoice_detail where inv_num = invoiceNum; if lineItemNum is null or lineItemNum = 0 then if detailCount > 0 then - select max(lineItemNum) into maxlineItemNo from invoice_detail where inv_num = invoiceNum; + select max(lineItemNum)+1 into maxlineItemNo from invoice_detail where inv_num = invoiceNum; else set maxlineItemNo = 1; end if; @@ -121,7 +121,7 @@ SELECT COUNT(line_item_no) INTO podetailCount FROM po_detail where po_num = ponu if lineItemNo is null or lineItemNo = 0 then if podetailCount > 0 then - select max(line_item_no) into maxlineItemNo from po_detail where po_num = ponum; + select max(line_item_no)+1 into maxlineItemNo from po_detail where po_num = ponum; else SET maxlineItemNo = 1; end if;