Java examples for JDBC:Stored Procedure
Create a function named myfunc which returns a VARCHAR value; the function has no parameter
import java.sql.Connection; import java.sql.Statement; public class Main { public static void main(String[] args) throws Exception{ Connection connection = null; Statement stmt = connection.createStatement(); String function =//w ww . j av a2 s .c o m "CREATE OR REPLACE FUNCTION myfunc RETURN VARCHAR IS " + "BEGIN " + "RETURN 'a returned string'; " + "END;"; stmt.executeUpdate(function); } }