为什么说游标变量可以减少网络流量啊

解决方案 »

  1.   

    也可以这么说吧。
    如果不使用cursor,比如使用分页语句一次取一行进行处理,那么提取数据的sql需要多次传输,增加网络负担。
    如果是cursor,可以一次取到客户端,然后对cursor进行遍历处理即可。
      

  2.   

    你说的是应该是游标变量和游标比较而言。
    看文档的说明:
    http://docs.oracle.com/cd/B19306_01/appdev.102/b14261/sqloperations.htm#sthref1392Why Use Cursor Variables?...If you have a PL/SQL engine on the client side, calls from client to server impose no restrictions. For example, you can declare a cursor variable on the client side, open and fetch from it on the server side, then continue to fetch from it back on the client side. You can also reduce network traffic by having a PL/SQL block open or close several host cursor variables in a single round trip.
    大概是说:
    如果在客户端有pl/sql引擎,那么从客户端调用服务器端。比如,你在客户端定义一个游标变量,然后在服务器端open和fetch,再把结果返回给客户端,这些操作都是在服务器端进行的,所以减少了网络流量。