所有 sql 输出的一个变量
myRs=myStmt.executeQuery("从 tab_col 中选择 i_col,col_name") 我=0 while (myRs.next()): list= myRs.getString("I_COL")+','+myRs.getString("COL_NAME")
我有一个 jython 代码来运行 sql 语句,我想将 sql 的所有行存储到单个变量中。我曾经用列表来存储值,但它总是只存储单行,所以有没有办法追加所有行并继续添加到单个变量。
非常感谢您的帮助。
myRs=myStmt.executeQuery("select i_col,col_name from tab_col")
i=0
while (myRs.next()):
list= myRs.getString("I_COL")+','+myRs.getString("COL_NAME")
i have a jython code to run a sql statement i want to store all the row of the sql into a single variable. I used to list to store the value but its always storing only the single line , so is there is way to append all the rows and keep adding to single variable.
Thanks so much for your help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用该代码,您可以在 while 循环的每次迭代中覆盖“list”变量(
=
是一个赋值),尝试这样的操作(我使用rs
而不是>list
以避免与内置函数list()
发生名称冲突):With that code you overwrite the "list" variable in every iteration of the while loop (
=
is an assignment), try something like this (I usedrs
rather thanlist
to avoid a name clash with the builtin functionlist()
):