oracle中如何获取未知列
Oracle 中是否有一个运算符可以获取结果集中的某一行的某一列,而无需指定该列的名称。我想要这样的东西:
for row in (select * from table1)
loop
for col in row
loop
// do stuff with col
end loop;
end loop;
谢谢。
Is there an operator in Oracle that fetch a column of a row in a result set without having to specify the column's name. I want something like:
for row in (select * from table1)
loop
for col in row
loop
// do stuff with col
end loop;
end loop;
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有为此的内置函数。您必须使用 DBMS_SQL 包才能使用动态 SQL: http://docstore .mik.ua/orelly/oracle/bipack/ch02_02.htm
There is no built in function for this. You will have to use DBMS_SQL package in order to use dynamic SQL : http://docstore.mik.ua/orelly/oracle/bipack/ch02_02.htm
在静态 SQL 中,没有。
如果您使用动态 SQL(通过 DBMS_SQL),您可以描述该语句并迭代列。但是,如果查询本身不是动态的,那么如果您转向使用 DBMS_SQL 而不是简单地编码您感兴趣的列名,那么几乎肯定会增加代码的复杂性并降低可维护性。
In static SQL, no.
If you were using dynamic SQL (via DBMS_SQL), you could describe the statement and iterate over the columns. But if the query itself is not dynamic, it would almost certainly increase the complexity of the code and decrease the maintainability if you were to move toward using DBMS_SQL rather than simply coding the column names that you're interested in.