【问题标题】:How to club all insert scripts into a function如何将所有插入脚本组合到一个函数中
【发布时间】:2019-05-21 04:28:46
【问题描述】:

我有四张桌子

来源---temp1---temp2----temp3--决赛桌

已创建所有插入脚本 + 一些临时表,用于将最终结果集派生到最终表中。

需要根据需要创建一个 oracle 过程/函数。

需要一个样本来合并相同的内容。对专家来说应该非常容易。

谢谢

【问题讨论】:

  • “对专家来说应该超级容易” - 为将来参考,通过查看the Oracle documentation (link) 查找样本“超级容易”。我想这是一个家庭作业。但愿如此。因为像这样的流程闻起来是不好的做法,在现实生活中应该是一个危险信号。
  • 感谢您的链接。我认为这不应该阻止我问问题是否超级简单,超级复杂

标签: oracle plsql


【解决方案1】:

我想应该是这样的。

create or replace procedure p_insert is
begin
  --  all your insert statements go in here
  insert into temp1 (col1, col2, ...)
    select a.col1, b.col2, ...
    from a join b on a.id = b.id
    where ...;

  insert into temp2 (col1, col3, ...)
    select ...
    from temp1
    where ...;

  etc.

  insert into final_table (col1, col2, col3, ...)
    select ...
    from temp3;
end;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多