更新时间:2021-12-05 21:36:41
您可以通过使用弱类型的Ref Cursor作为返回类型来实现此目的.通过使用JDBC的客户端接口,这特别容易实现,因为返回的游标类型可以像任何查询结果一样逐步执行,并且可以从ResultSet.getMetaData()询问元数据.这是一个示例:
You can implement this by using a weakly-typed Ref Cursor as the return type. This is especially easy to implement from a client interface using JDBC, as the returned cursor type can be stepped through just like any query result and the metadata can be interrogated from ResultSet.getMetaData(). Here's an example:
CREATE OR REPLACE PROCEDURE retrieve_info(field_id in integer, p_cursor in out sys_refcursor)
AS
BEGIN
open p_cursor for 'select * from emp';
END;
带引号的查询可以是返回任何类型,任何数量列的任何内容.
The query in quotes could be anything returning any type, for any number of columns.