The tip works exactly !!!

Thanks for your attention.

Em sex., 24 de mar. de 2023 às 22:45, Evgenij Ryazanov <[email protected]>
escreveu:

> With JDBC, you can call your function either with PreparedStatement or
> with CallableStatement:
>
> try (Connection c = DriverManager.getConnection("jdbc:h2:mem:1")) {
>
> Statement s = c.createStatement();
>
> s.execute("CREATE ALIAS my_stored_proc AS 'BigDecimal send() { return
> BigDecimal.ONE; }'");
>
> // With PreparedStatement
>
> PreparedStatement ps = c.prepareStatement("CALL my_stored_proc()");
>
> ResultSet rs = ps.executeQuery();
>
> rs.next();
>
> System.out.println(rs.getBigDecimal(1));
>
> // With CallableStatement
>
> CallableStatement cs = c.prepareCall("{? = CALL my_stored_proc()}");
>
> cs.registerOutParameter(1, Types.NUMERIC);
>
> cs.execute();
>
> System.out.println(cs.getBigDecimal(1));
>
> }
>
> In case of callable statement you should register the output parameter
> only, because your function doesn't have any input parameters. It is also
> possible to use it without registration of output parameter, in that case
> result can be read from it in the same way as from prepared statement.
>
> You use a wrapper over JDBC, it has a different API, but situation in the
> same. Your function doesn't have any input parameters, it means you
> shouldn't try to pass them here, hypothetically SimpleJdbcCall can be
> confused by that unexpected parameter. You can try to run it without
> parameters. But I never used that library, so I can't be sure.
>
> --
> You received this message because you are subscribed to the Google Groups
> "H2 Database" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/h2-database/927ea4e9-60d0-41ad-b186-95202b3bdcfan%40googlegroups.com
> <https://groups.google.com/d/msgid/h2-database/927ea4e9-60d0-41ad-b186-95202b3bdcfan%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/h2-database/CAMbOUNR_awWDghoRLoVJ0n2RdKoZ5xLL9rk%2BwO8Ue0i7miNtGQ%40mail.gmail.com.

Reply via email to