SQLを使用してデータベースからデータをフェッチしています。where句に変数を渡す必要がありますが、公式の例でも文字列の連結が機能しないことがわかりました。
* def batchnum = "112344552"
* def getBatchIDSQL = '#("select id from sr_sendreceive where batchnum = " + batchnum)'
* print getBatchIDSQL
* def sendReceiveBatchid = db.readValue('#(getBatchIDSQL)')
次に、公式の例を試しました。
# wrong !
* def foo = 'hello #(name)'
# right !
* def foo1 = '#("hello " + name)'
* print foo1
* def name = 'test name'
* def temp = 'hello ' + name
* def foo2 = '#(temp)'
* print foo2
結果は次のとおりです。
#("select id from sr_sendreceive where batchnum =" + batchnum)
#("hello " + name)
#(temp)
申し訳ありませんが、ドキュメントが間違っています。これは、JSON以外の場合にのみ機能しmatch
ます。このような:
* def batchnum = "112344552"
* def actual = 'select id from sr_sendreceive where batchnum = 112344552'
* match actual == '#("select id from sr_sendreceive where batchnum = " + batchnum)'
JSON内では機能します:
* def foo = { bar: '#("select id from sr_sendreceive where batchnum = " + batchnum)' }
* print foo
これを指摘してくれてありがとう、私はドキュメントを更新します。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加