oracle oracle中强弱ref_cursor的区别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6042568/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:41:59  来源:igfitidea点击:

Difference between strong and weak ref_cursor in oracle

oracleplsqlcursor

提问by Preeti

I want to know the practical difference between strong and weak ref cursor.

我想知道强和弱之间的实际区别ref cursor

Strong ref_cursorwill always use to return a value and compiler know the structure during the compile time, but in the weak ref cursorit will not return a value and compiler dosen't know the structure during the compile time.

强将ref_cursor始终使用返回值,编译器在编译期间知道结构,但在弱中ref cursor它不会返回值并且编译器在编译期间不知道结构。

This is the basic difference but my question is what value will be returned by the strong ref cursorand where that returned value will be used.

这是基本的区别,但我的问题是强将返回什么值以及将在ref cursor何处使用该返回值。

回答by Datajam

A strongly typed ref cursor always returns a known type, usually from a declared TYPE object. The compiler can find problems in a PL/SQL block by comparing the types returned to how they are used.

强类型引用游标始终返回已知类型,通常来自声明的 TYPE 对象。编译器可以通过比较返回的类型和它们的使用方式来发现 PL/SQL 块中的问题。

A weakly typed ref cursor has a return type that is dependant on the SQL statement it executes, i.e. only once the cursor is opened is the type known (at runtime). The compiler cannot determine the types until it is ran, so care must be taken to ensure that the cursor result set is handled properly to avoid runtime errors.

弱类型引用游标的返回类型取决于它执行的 SQL 语句,即只有在游标打开后才是已知类型(在运行时)。编译器在运行之前无法确定类型,因此必须注意确保正确处理游标结果集以避免运行时错误。

回答by GKV

there is one more difference between strong and weak reference cursor is that dynamic query is not possible in strong reference cursor where as it is possible in weak reference cursor

强引用游标和弱引用游标之间还有一个区别是动态查询在强引用游标中是不可能的,而在弱引用游标中是可能的