Subject | S.Proc |
---|---|
Author | Revcor Stump |
Post date | 2013-09-10T17:14:14Z |
Good Day,
Could someone please correct below s.proc. syntax.
Thank You
CREATE PROCEDURE BOMCOST (
"ITEMNO" VARCHAR(20) )
RETURNS
( "CHILDITEMNO" VARCHAR(20),
"QTY" NUMERIC(18, 2),
"LASTPRICE" NUMERIC(18, 4),
"AVGCOST" NUMERIC(18, 4))
AS
BEGIN
/*First i'd like to collect LastPurchasePrice & AverageCost of the items
/*from ITEMSMOVE View.
FOR
SELECT SUM(NETPRICE * QTY)/SUM(QTY) FROM ITEMSMOVE
INTO : AVGCOST
/*Then i'd like get the last purchase price from the upper same View*/
SELECT UPRICE
FROM ITEMSMOVE
WHERE (ITEMNO=:"ITEMNO") and
TDATETIME=(SELECT MAX(TDATETIME) FROM ITEMSMOVE
WHERE TNAME IN ('B','M', 'T' ))
INTO : LASTPRICE
Now i'd like to combain above LASTPRICE & AVGCOST with
below ITEMS (Parts)
SELECT B.CHILDITEMNO, B.QTY
FROM BOM B
WHERE B.ITEMNO= : ITEMNO
INTO : CHILDITEMNO,: QTY
DO
SUSPEND;
END
Could someone please correct below s.proc. syntax.
Thank You
CREATE PROCEDURE BOMCOST (
"ITEMNO" VARCHAR(20) )
RETURNS
( "CHILDITEMNO" VARCHAR(20),
"QTY" NUMERIC(18, 2),
"LASTPRICE" NUMERIC(18, 4),
"AVGCOST" NUMERIC(18, 4))
AS
BEGIN
/*First i'd like to collect LastPurchasePrice & AverageCost of the items
/*from ITEMSMOVE View.
FOR
SELECT SUM(NETPRICE * QTY)/SUM(QTY) FROM ITEMSMOVE
INTO : AVGCOST
/*Then i'd like get the last purchase price from the upper same View*/
SELECT UPRICE
FROM ITEMSMOVE
WHERE (ITEMNO=:"ITEMNO") and
TDATETIME=(SELECT MAX(TDATETIME) FROM ITEMSMOVE
WHERE TNAME IN ('B','M', 'T' ))
INTO : LASTPRICE
Now i'd like to combain above LASTPRICE & AVGCOST with
below ITEMS (Parts)
SELECT B.CHILDITEMNO, B.QTY
FROM BOM B
WHERE B.ITEMNO= : ITEMNO
INTO : CHILDITEMNO,: QTY
DO
SUSPEND;
END
The result should be like below
CHILDITEMNO...QTY....AVGCOST.....LASTPRICE
AA...........................2............1200...............1220
BB...........................4...............600................630
.......