【发布时间】:2019-10-01 02:43:33
【问题描述】:
我正在将 oracle 代码迁移到 postgresql,我需要将查询附加到现有日志文件。
基本上我想要在 PostgreSQL 中等效于 oracle 命令“SPOOL test.log APPEND”。有没有办法做到这一点?
我尝试使用 \o 或 \o+ 将新数据附加到日志文件或在 PostgreSQL 中复制,但它会覆盖日志文件。
我的代码是这样的:
甲骨文:
spool test.log
select uid from users where uid='1111';
spool off
select sysdate from dual;
//other business logic code
-
spool test.log append
select balance from balances where uid='1111';
spool off
Postgresql:
\o test.log
select uid from users where uid='1111';
\o
select current_date;
//other business logic code
-
\o test.log
select balance from balances where uid='1111';
\o
我希望 \o 块中的两个查询附加到 PostgreSQL 中的同一个文件。
【问题讨论】:
标签: postgresql database-migration plpgsql