PL/SQL中的游标对象是什么
我理解 PL/SQL 变量的概念,但我无法清楚地了解 PL/SQL 中的游标对象。
我在某处读过下面的文字,感觉自己无法理解光标对象的概念。
“如果光标变量还没有 已分配给任何光标对象, 隐式 OPEN FOR 语句 为变量创建一个对象。
如果在 OPEN 时光标 变量已经指向一个 游标对象,则 OPEN FOR 不会 创建一个新对象。相反,它 重用现有对象并且 将新查询附加到该对象。 光标对象被维护 与游标或查询分开 本身。 ”
请解释一下它的内部工作原理......
I understand the concept of PL/SQL variables but I am unable to get clear picture of cursor objects in PL/SQL in my mind.
I have read the below written text somewhere and and feel myself unable to understand the concept of cursor objects.
"If the cursor variable has not yet
been assigned to any cursor object,
the OPEN FOR statement implicitly
creates an object for the variable.
If at the time of the OPEN the cursor
variable already is pointing to a
cursor object, then OPEN FOR does not
create a new object. Instead, it
reuses the existing object and
attaches a new query to that object.
The cursor object is maintained
separately from the cursor or query
itself. "
please explain me how it works internally.....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你可以把它看作C编程语言中使用的指针(如果你学过的话),它指向从SQL语句中检索的每一行数据。将光标移动到下一行以读取下一行。
参考:http://www.cse.unsw。 edu.au/~cs9311/10s2/lectures/week04/PL_SQL.pdf
这是我用来学习PL/SQL的讲义
you can regard it as a pointer which is used in C programming language(if you ever have learnt), it points to each row of the data retrieved from the SQL statement. Move the cursor to next line to read the next row.
Ref: http://www.cse.unsw.edu.au/~cs9311/10s2/lectures/week04/PL_SQL.pdf
this is the lecture notes which I used to learn PL/SQL
据我了解,游标就像指向结果集中的行的指针。在其他编程语言中,它就像一个枚举器。枚举器是一个帮助遍历项目集合的对象。
例如:
在 C# 中与此类似:
请注意,使用游标来获取记录数据类似于使用枚举器来获取数据。
希望这对您有帮助。
To my understand, a cursor is like a pointer that point to a row in a result set. In other programming language, it is like a enumerator. A enumerator is a object that helps goes though a collection of items.
For example:
would be similar to this in C#:
Notice that you use the cursor to get record data is similar to use a enumerator to get the data.
Hope this helps you.