小编Wha*_*ark的帖子

PostgreSQL 选择 INTO 函数

我正在编写一个函数,它将选择结果输出并将其汇总到一个新表中 - 因此我尝试使用 INTO 函数。但是,我的独立代码可以工作,但是一旦进入函数,我就会收到一条错误消息,指出新的 SELECT INTO 表不是已定义的变量(也许我遗漏了一些东西)。请看下面的代码:

CREATE OR REPLACE FUNCTION rev_1.calculate_costing_layer()
  RETURNS trigger AS
$BODY$
BEGIN
   -- This will create an intersection between pipelines and sum the cost to a new table for output
   -- May need to create individual cost columns- Will also keep infrastructure costing seperated
   --DROP table rev_1.costing_layer;
   SELECT inyaninga_phases.geom, catchment_e_gravity_lines.name, SUM(catchment_e_gravity_lines.cost) AS gravity_sum
   INTO rev_1.costing_layer
   FROM rev_1.inyaninga_phases 
   ON ST_Intersects(catchment_e_gravity_lines.geom,inyaninga_phases.geom)
   GROUP BY catchment_e_gravity_lines.name, inyaninga_phases.geom;
  RETURN NEW;
END;
$BODY$
language plpgsql
Run Code Online (Sandbox Code Playgroud)

postgresql postgis create-table insert-into

1
推荐指数
1
解决办法
1631
查看次数

JavaScript 从数组构建数组

我目前有一个有 2 个级别的数组。我试图从初始数组构建两个新数组,但似乎坚持使用的方法。我尝试了 forEach()、while 循环以及 push 都无济于事。

我当前的数组结构:

[
  {
    "attributes": {
      "Summary": 10,
      "class": "Blue"
    }
  },
  {
    "attributes": {
      "Summary": 63,
      "class":"Red"
    }
  }
]
Run Code Online (Sandbox Code Playgroud)

我希望构建两个数组,一个用于汇总值,另一个用于类值。

我的 forEach 或 while 循环方法是否在正确的路径上?

javascript

1
推荐指数
1
解决办法
48
查看次数