|
@@ -12,7 +12,7 @@ FROM zone_* WHERE project_id='Pj4201050001' AND floor_id is not null
|
|
|
## 实现方式
|
|
|
SQL
|
|
|
```
|
|
|
-update zone_air_conditioning zone set zone.building_id = floor.build_id from floor where zone.floor_id = floor.id and zone.project_id = 'Pj4201050001' and zone.floor_id is not null
|
|
|
+update zone_air_conditioning zone set zone.building_id = floor.building_id from floor where zone.floor_id = floor.id and zone.project_id = 'Pj4201050001' and zone.floor_id is not null
|
|
|
```
|
|
|
|
|
|
# 函数
|
|
@@ -25,7 +25,7 @@ try:
|
|
|
# 将下面对数据库的操作作为一个事务, 出异常则自动rollback
|
|
|
with plpy.subtransaction():
|
|
|
for table in list:
|
|
|
- str = "UPDATE {0} as zone SET building_id = floor.build_id from public.floor as floor where floor_id = floor.id and zone.project_id = $1 and floor_id is not null".format(table.strip())
|
|
|
+ str = "UPDATE {0} as zone SET building_id = floor.building_id from public.floor as floor where floor_id = floor.id and zone.project_id = $1 and floor_id is not null".format(table.strip())
|
|
|
plan = plpy.prepare(str, ["text"])
|
|
|
data = plan.execute([project_id])
|
|
|
except Exception as e:
|