Stored Procedure in H2 Database

后端 未结 4 2063
旧时难觅i
旧时难觅i 2020-12-06 10:44

I am new to database and recently started writing test cases for H2 database. I want to know how to test a stored procedure in Eclipse. I have seen the following:

ht

4条回答
  •  Happy的楠姐
    2020-12-06 11:16

    There is no stored procedure and sql userdefined function in H2 database instead of that we use java methods and create a alias to refer that.We can call that methods using alias.

    Below is a simple example:**

    DROP ALIAS IF EXISTS MYFUNCTION;
    CREATE ALIAS MYFUNCTION AS $$
    String getTableContent(java.sql.Connection con) throws Exception {
        String resultValue=null;
        java.sql.ResultSet rs = con.createStatement().executeQuery(
        " SELECT * FROM TABLE_NAME");
           while(rs.next())
           {
            resultValue=rs.getString(1);
           }
        return resultValue;
    }
    $$;
    

提交回复
热议问题