1

SQL から返されたいくつかの行を grails 選択に入力しようとしていますが、何らかの理由で機能していません。次のコードがあります。

コントローラ:

import groovy.sql.Sql

class ClinicalRequirementsController {

static allowedMethods = [save: "POST", update: "POST", delete: "POST"]

def dataSource //injection of dataSource 

def create() {

     def db = new Sql(dataSource)

     def terms = db.rows("""SELECT stvterm_code
     FROM stvterm
     WHERE stvterm_fa_proc_yr = (SELECT stvterm_fa_proc_yr
     FROM stvterm, current_term
     WHERE stvterm_code = current_term.cur_term)
     ORDER BY stvterm_code ASC""")

     [terms: terms]

     db.close()

     [clinicalRequirementsInstance: new ClinicalRequirements(params)]
   }
}

GSP セレクト:

<g:select name="insuranceSemesterVerified" from="${terms}" required=""   value="${clinicalRequirementsInstance?.insuranceSemesterVerified}" valueMessagePrefix="clinicalRequirements.insuranceSemesterVerified"/>

私はかなり困惑しています。うまくいけば、誰かが私を間違っているところに向けることができます。他の場所のデータベースに対してクエリを既に確認しました。

4

1 に答える 1

0

コントローラーは最後の行のみを返すため (returnどこかにステートメントを配置しない限り)、最後の行を次のように変更します。

[clinicalRequirementsInstance: new ClinicalRequirements(params), terms: terms]
于 2012-10-26T22:13:40.603 に答える