|
5#
楼主 |
发表于 2015-10-23 15:30
|
只看该作者
guostong 发表于 2015-10-16 01:29
https://www-304.ibm.com/support/knowledgecenter/SSULQD_7.2.0/com.ibm.nz.sproc.doc/c_sproc_iterative_ ...
E文阅读能力有限....
仔细看了你发的ibm知识库网站,找到了如下内容:
https://www-304.ibm.com/support/ ... ynamic_queries.html
A query run by an EXECUTE IMMEDIATE statement is prepared each time the statement is run. The query string can be dynamically created within the procedure to do actions on different tables and fields.
The results from SELECT queries are discarded by EXECUTE IMMEDIATE, and SELECT INTO is not currently supported within EXECUTE IMMEDIATE. So, the only way to extract a result from a dynamically created SELECT is to use the FOR ... EXECUTE form, described in Iterate through the records of a query.
好像是说select into 不能用在execute immediate里,唯一能提取动态select结果是使用 FOR...EXECUTE .
然后按照提示的有点开了:Iterate through the records of a query.
https://www-304.ibm.com/support/ ... hrough_records.html
The FOR-IN EXECUTE statement is another way to iterate over records:
[<<label>>]
FOR record | row IN EXECUTE text_expression LOOP
statements
END LOOP;
This form is similar to the previous form, except that the source SELECT statement is specified as a string expression. The main difference between the two is the syntax and use of variables to build the SQL to run. The first form is faster to evaluate.
这里看了个半懂,但是没有例子,还是不清楚怎么用。版主能帮我看下吗? |
|