代码之家  ›  专栏  ›  技术社区  ›  Omnipresent

如何使用oracle包中找到的行来避免两个查询

  •  1
  • Omnipresent  · 技术社区  · 16 年前

    select * from table(my_package.my_function(99, 'something, something2', 1, 50))
    

    我在存储过程中使用包。示例存储过程如下所示:

    insert into something values(...) 
    from 
    (select * from table(my_package.my_function(99, 'something, something2', 1, 50))) a
    other_table b
    where b.something1 = a.something1;
    
    open cv_1 for 
    select count(*) from 
    table(my_package.my_function(99, 'something, something2', 1, 50))
    

    有没有一种方法可以第一次得到计数并将其放入一个变量中,第二次我只是选择那个变量而不是再次调用整个查询?

    希望有道理。

    1 回复  |  直到 16 年前
        1
  •  4
  •   Tony Andrews    16 年前

    insert into something (...) 
    select * from table(my_package.my_function(99, 'something, something2', 1, 50))) a
    other_table b
    where b.something1 = a.something1;
    
    l_count := SQL%ROWCOUNT;