relation with OID 637165 does not exist
執行儲存報錯物件表不存在,而且這個OID還會變,儲存中有段如下程式碼,迴圈刪除、刪除並使用同一個臨時表表名,猜測和臨時表有關 。查詢資料得知PostgreSQL版本<8.3(GP4.3.8是pg8.2引擎),如果一個PL / pgsql函式訪問一個臨時表,然後這個臨時表刪除並重新建立,並再次呼叫,該函式會失敗,因為快取的功能內容仍指向老 臨時表
dt:='2015-11-01 00:00:00'::date;
while dt<now() loop
drop table if EXISTS t3;
create TEMPORARY table t3 as (
select test.*
,SUM(amount) OVER (PARTITION BY user_id ORDER BY date) AS s1
from test
where date<dt
);
drop table if EXISTS t4;
create TEMPORARY table t4 as (
select user_id,sum(-amount) as amount
from test
where date<dt GROUP BY user_id
);
INSERT INTO equ
select t3.user_id,t3.date as BEGIN,null as end,case when s1-t4.amount<t3.amount then s1-t4.amount else t3.amount end,3 as flag
from t3 left join t4
on t3.user_id=t4.user_id and t3.s1>t4.amount where to_number(date,'9999999')=to_number(dt,'9999999');
dt:=dt + INTERVAL '1 month';
end loop;
把臨時表換成子查詢解決
dt:='2015-11-01 00:00:00'::date;
while dt<now() loop
INSERT INTO equ
select t3.user_id,t3.date as BEGIN,null as end,case when s1-t4.amount<t3.amount then s1-t4.amount else t3.amount end,3 as flag
from
(
select test.*
,SUM(amount) OVER (PARTITION BY user_id ORDER BY date) AS s1
from test
where date<dt
) t3 left join
(
select user_id,sum(-amount) as amount
from test
where date<dt GROUP BY user_id
)t4
on t3.user_id=t4.user_id and t3.s1>t4.amount where to_number(date,'9999999')=to_number(dt,'9999999');
dt:=dt + INTERVAL '1 month';
end loop;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29989552/viewspace-2128284/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- pgsql 執行建庫指令碼時候出現ERROR: relation "xxx_id_seq" does not existSQL指令碼Error
- PSQLexception: ERROR : type "signed" does not existSQLExceptionError
- Property [title] does not exist on this collection instance
- Waring: /dev/centos/swap does not existdevCentOS
- Property 'context' does not exist on type 'NodeRequire'.ts(2339)ContextUI
- Laravel Class env does not exist 問題排查Laravel
- ORA-04043: object DBA_DATA_FILES does not existObject
- [20211231]ORA-01418 specified index does not exist.txtIndex
- dcat-admin 表單 Field type [autocomplete] does not exist.
- ORA-30012 undo tablespace 'UNDOTBS3' does not exist or of wrong typeS3
- The operation, ‘DecodeJpeg/contents‘, does not exist in the graph.錯誤解決方法
- yii2接入pgSQL(查詢不到表The table does not exist: {{%user}})SQL
- Android解決The APK file app-debug.apk does not exist on disk.AndroidAPKAPP
- streamlit run執行報錯,Invalid value: File does not exist: XXX.py
- 靜默安裝Oracle建庫時報Template General Purpose does not existOracle
- Error: The directory named as part of the path ./log/supervisord.log does not exist解決方案Error
- Eclipse裡Tomcat報錯:Document base ……does not exist or is not a readable directory(圖文詳解)...EclipseTomcat
- git中出現”the requested upstream branch ‘origin/master‘ does not exist“問題的解決GitAST
- Hadoop的mapreduce出現問題,報錯The auxService:mapreduce_shuffle does not existHadoopUX
- 安裝kernel...src.rpm錯誤:warning: user mockbuild does not exist - using rootMockUI
- ABAP 資料結構啟用時的錯誤訊息 - combination reference table field does not exist資料結構
- What is an SQL relation?SQL
- mac scrcpy 報錯 does not exist or is not a regular file,ERROR: Server connection failed(scrcpy mac與極空間衝突)MacErrorServerAI
- SAP對工單做101收貨,報錯- Check table TFBEFU_CR entry 10 does not exist–對策
- oid轉blob問題
- SAP MM 對採購訂單執行收貨,報錯 - Table T169P entry ZNMI does not exist -
- How to draw a simple relation graph in PythonPython
- SQL not exist out joinSQL
- [ABC126D] Even Relation 題解
- ‘map’ does not name a type
- What does -> do in clojure?
- does not support SSL connections
- sql case when, Exist ,group by ,聚合SQL
- 【RAC啟動故障】ORA-21561: OID generation failedAI
- PostgreSQL中將物件oid和物件名相互轉換SQL物件
- What does "xargs grep" do?
- error: 'cout' does not name a type|Error
- error: ‘xxx’ does not name a typeError
- The label does not denote a loop in forEachOOP