gpt4 book ai didi

windows - Postgres 9.0 linux命令到windows命令的转换

转载 作者:太空宇宙 更新时间:2023-11-04 09:52:06 25 4
gpt4 key购买 nike

我正在开发一个应用程序,使用 delphi 7 作为前端,使用 postgres 9.0 作为后端。

我必须将图像上传到服务器,所以我使用 \lo_import\lo_export 在服务器上插入图像并从服务器获取图像。

我遇到了一个问题,在 \lo_import 之后需要 LASTOID,所以我可以使用 OID 更新我表中的一行,但我无法设置Windows 语法正确

UPDATE fishes
SET fishesimages=17755; -- <--last OID
WHERE fishes='0A';

这是我关于 stackoverflow.com 的问题.我得到了答案,但脚本是 Linux shell 脚本。我无法在 Windows 中运行它

psql -h 192.168.1.12 -p 5432 -d myDB -U my_admin << EOF
\lo_import '/path/to/my/file/zzz4.jpg'
UPDATE species
SET fishesimages = :LASTOID
WHERE fishes = '04';
EOF

echo "\lo_import '/path/to/my/file/zzz4.jpg' \\\\ UPDATE species SET fishesimages =   :LASTOID WHERE  fishes = '04';" | \
psql -h 192.168.1.12 -p 5432 -d myDB -U my_admin

我在windows下试过

"C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h 192.168.1.12 -p 5432 -d myDB -U my_admin -c "\lo_import 'C://im/zzz4.jpg'"; 

然后立即(以编程方式)我正在做

"C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h 192.168.1.12 -p 5432 -d myDB-U myDB_admin -c " update species SET fishesimages = :LASTOID WHERE fishes='24'" 

但是我在“:”处或附近出现语法错误

谁能告诉我如何将其转换为 Windows commnad?

最佳答案

只需将命令放在一个文件中(比如 import.psql)

-- contents of import.psql
\lo_import '/path/to/my/file/zzz4.jpg'
UPDATE species
SET speciesimages = :LASTOID
WHERE species = 'ACAAC04';

发出命令

"C:\Program Files\PostgreSQL\9.0\bin\psql.exe" -h 192.168.1.12 -p 5432 -d myDB -U my_admin -f import.psql

关于windows - Postgres 9.0 linux命令到windows命令的转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9798775/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com