grails调用postgresql存储过程并取得输出值

输出字符串
def dataSource
def test={
  Sql sql = new Sql(dataSource);
  def invar="testvar";
  sql.call("{call yourfunction(${Sql.inout(Sql.VARCHAR(invar))}) }") {
                       string -> 
                       render(string)
                     }
}


输出record记录集
def dataSource
def test={
  Sql sql = new Sql(dataSource);
  def var1="testvar1";
  def var2="testvar2";
  def data = sql.rows("select * from yourfunction('${var1}','${var2}')")
		     data.each{
                      render it.name
		     }
}

你可能感兴趣的:(java,sql,PostgreSQL,grails)