我需要將%
字符轉換爲SQL查詢,並將其傳遞給Windows批處理文件。我的問題是這個角色沒有被考慮在內。批處理文件:將%字符轉義爲PostgreSQL查詢
towns=(12232, 12233)
for %%a in %towns% do (
"C:\Program Files\PostgreSQL\9.4\bin\pgsql2shp.exe" -h localhost -u thomas -P password thomas_db "SELECT * FROM schema.table WHERE code like '%%a%'"
)
我得到以下錯誤:
C:\batch><"C:\Program Files\PostgreSQL\9.4\bin\pgsql2shp.exe" -h localhost -u thomas -P password thomas_db "SELECT * FROM schema.table WHERE code like '12232'"> Initializing... ERROR: Could not determine table metadata
的LIKE '%%a%'
被解釋爲LIKE '12232'
和應爲LIKE '12232%'
。
'喜歡 '%#%一%' 逃跑 '#'' – jarlh