简体   繁体   中英

Oracle 12c PLSQL MERGE error

The below code snippet is from a larger procedure of mine. When I execute this procedure manually in TOAD it works without error as I would expect.

I am now trying to put it into a form for the user - however when I try to compile it I get the following error on the MERGE line: "Encountered the symbol "INTO" when expecting one of the following: :=.(@%;"

MERGE INTO count_balance cb
USING (select location_code, product_code, closing_stock
       from trd_stock_closing ts
      where period = gen.add_periods(p_period, -1)
        and exists (select null
                      from ag_product_view
                     where product_code = ts.product_code
                       and group_code = 'Q')) cs
ON (cb.location_code = cs.location_code AND cb.product_code = cs.product_code)
WHEN MATCHED THEN 
UPDATE SET cb.opening_stock = cs.closing_stock
WHEN NOT MATCHED THEN
INSERT (location_code, product_code, opening_stock)
VALUES (cs.location_code, cs.product_code, cs.closing_stock);

Can someone advise?

It looks like you're trying to use good old Oracle*Forms, which have no support for MERGE statement at all. Try either use the newer version of Forms or wrap this code into stored procedure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM