我正在使用Postgres 12,并编写了以下过程:
CREATE OR REPLACE PROCEDURE reduceStock(id INTEGER, soldQuantity INTEGER)
LANGUAGE plpgsql AS
$$
BEGIN
UPDATE inventory SET ProductStockAmount = ProductStockAmount - soldQuantity WHERE ProductID = id;
END;
$$;
It works perfectly if I open up psql on the command line and run call reduceStock(1,1);
但是,从我的Java程序中调用它如下:
CallableStatement stmt = conn.prepareCall("{call reduceStock(?, ?)}");
stmt.setInt(1, productID);
stmt.setInt(2, quantity);
stmt.execute();
我尝试过的
- running
call reduceStock(1,1);
from the psql client - works perfectly - dropping the database and starting over to see if some old definition was cached - didn't work
- different capitalisations, spacings of
call
任何想法,将不胜感激