0

我在 PLSQL 中有一个填充临时表的过程。数据如下所示:

BUYER_NAME  QUANTITY   AMOUNT
-------------------------------
JOHN        10         1200
JOHN        12         1310
ALAN        15         1450
ALAN        10         1200
JOHN        20         2400

我需要总结每个买家的数量和金额,然后删除现有数据并再次填写表格,以便每个买家名称仅出现一次总数量和金额。

我知道如果我创建另一个临时表并通过它传输数据,就可以做到这一点。但是,有没有一种方法可以合并同一个临时表(以及同一个会话)中的记录?

4

1 回答 1

0

It sounds like the problem here is with the initil pl/sql procedure that fills the table. Why not modify it to do this as well? I suspect that the answer would be that it makes much use of pl/sql -- if so, make every effort to convert it to SQL instead, or turn it into a pipelined function that you can select from and aggregate the output of.

That aside, I would just aggregate the result into a different table. I assume that these are global temporary tables, so there is really not much overhead in doing so as a direct path insert to a GTT would be much more efficient than modifying a table already in place.

于 2013-04-20T07:16:09.817 回答