Function of postgres executed from java

0

I have a function in PostgreSQL that takes 6 values, the first one character varying , the next one an integer and the remaining 4 are of type numeric . I call it from Java in the following way:

preStmt=con.prepareStatement("SELECT 
sp_ins_act_productounidad(?,?,?,?,?,?);");
preStmt.setString(1, entPU.getProd_cod());
preStmt.setInt(2, entPU.getUni_codigo());
preStmt.setDouble(3, entPU.getPu_minimo());
preStmt.setDouble(4, entPU.getPu_maximo());
preStmt.setDouble(5, entPU.getPu_precionormal());
preStmt.setDouble(6, entPU.getPu_precioespecial());
rs=preStmt.executeQuery();

I get the following error:

  

there is no function sp_ins_act_productounidad (character varying,   integer, double precision, double precision, double precision, double   precision)       Hint: No function matches the name and types of arguments. It may be necessary to add explicit conversion of types.

I tried the function from PostgreSQL and it does not give me any problem but when calling it from Java it throws me that error, I also tried changing the data type by Float

    
asked by Leo T 25.09.2017 в 22:02
source

1 answer

0

The problem I had is that in my function I was receiving the values of type numeric , I had to change the values to type float and in java send the same type type float with this my problem was solved

The code used in the function was:

CREATE OR REPLACE FUNCTION public.sp_ins_act_productounidad(
_prod_cod character varying,
_uni_codigo integer,
_pu_minimo double precision,
_pu_maximo double precision,
_pu_precionormal double precision,
_pu_precioespecial double precision)

When declaring the function and saving it, the value of float is changed by double precision .

In java the following:

preStmt=con.prepareStatement("SELECT sp_ins_act_productounidad(?,?,?,?,?,?);");
preStmt.setString(1, entPU.getProd_cod());
preStmt.setInt(2, entPU.getUni_codigo());
preStmt.setFloat(3, entPU.getPu_minimo());
preStmt.setFloat(4, entPU.getPu_maximo());
preStmt.setFloat(5, entPU.getPu_precionormal());
preStmt.setFloat(6, entPU.getPu_precioespecial());
rs=preStmt.executeQuery();
    
answered by 25.09.2017 в 22:10