假设数据库中有表order和product代码如下 
DECLARE 
TYPE order_product_record_type IS RECORD( 
order_record order%ROWTYPE; 
product_record product%ROWTYPE; 
); 
order_product_record order_product_record_type ; 
TYPE order_product_table_type IS TABLE OF order_product_record_type; 
order_product_table order_product_table_type ; 
CURSOR order_product_cursor IS select a.*,b.* from order a,product b where a.productid= b.productid; 
BEGIN 
OPEN order_product_cursor ; 
FETCH order_product_cursor BULK COLLECT INTO order_product_table; 
CLOSE order_product_cursor; 
END; 
执行编译的时候系统通知我FETCH order_product_cursor BULK COLLECT INTO order_product_table;中order_product_table的类型不对 
请问 select a.*,b.* 这种查询方式游标返回的类型是什么 如何解决 望高人指教

解决方案 »

  1.   

    返回的类型和fetch表中的对应列类型一样
      

  2.   

    LZ 的类型定义真是复杂啊
    两点建议
    1、order 是Oracle 的关键字,不应该作为表名
    2、select a.*,b.* from order a,product b where a.productid= b.productid;
    这样的 SQL 查询结果应该有两个字段productid 和productid1 
    这样和你上面的定义
    order_record order%ROWTYPE; 
    product_record product%ROWTYPE; 其中就会有一个 productid1 不对应所以建议LZ不要偷懒,还是用 select a.xx,a.yy,b.aa,b.bb from a,b 
    的形式只查询需要的字段,不过这样的话下面这种定义形式就不可取了
    order_record order%ROWTYPE; 
    product_record product%ROWTYPE;