我在postgres
数据库中编写了以下存储过程
create or replace function reviseTax(revisiondate date, taxrate decimal) returns table(employeeid integer, month date, difference decimal) AS $$
declare
thisrow record;
newTaxAmt decimal;
differenceAmt decimal;
begin
for thisrow in select * from employee_salary where salarydate >= revisiondate loop
newTaxAmt = thisrow.income * $2;
differenceAmt = newTaxAmt - thisrow.tax;
update employee_salary es set tax = newTaxAmt where es.employeeid = thisrow.employeeid;
insert into taxrevision (employeeid , month , difference) values (thisrow.employeeid , thisrow.salarydate , differenceAmt);
end loop;
return query select * from taxrevision as something;
end $$ language plpgsql;
从数据库调用时,这工作正常。问题是当我使用 JDBC 代码从 java 调用这个存储过程时
我的java代码如下
System.out.println("Enter the effective date(yyyy-mm-dd) for the tax revision");
dateString = scanner.next();
float newTaxRate = 0.3F;
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
df.setLenient(false);
java.util.Date utilDate = df.parse(dateString);
java.sql.Date sqlDate = new java.sql.Date(utilDate.getTime());
CallableStatement callable = DBConnection.prepareCall("{call revisetax(?,?)}");
callable.setDate(1,sqlDate);
callable.setFloat(2,newTaxRate);
callable.executeQuery();
DBConnection.commit();
我收到以下错误:
ERROR: function revisetax(unknown, real) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 14
我无法弄清楚为什么,请帮助!