我在SQLSTATE = 42703 SQL0206N
的查询中遇到错误db2 export to prc_sec_01.txt of del
SELECT PRICE.PRC_SECURITY_ID,
\(decimal\(PRICE.PRC_PRICE\)\),
PRICE.PRC_CURRENCY,PRICE.PRC_CURRENCY
FROM RISKAPP.PRICE as PRICE
inner join RISKAPP.SECURITY as SECURITY
on PRICE.PRC_SECURITY_ID = SECURITY.SEC_SECURITY_ID
and SECURITY.SEC_TYPE = "E"
AND SECURITY.SEC_MATURITY_DATE >='20141118'
AND PRICE.PRC_EXTRACT_PERIOD ='PBNS'
AND PRICE.PRC_LAST_UPDATE_TMS >= '2014-10-01'
答案 0 :(得分:2)
首先,您需要根据需要测试查询。请尝试仅运行选择。如果有很多行,则可以仅使用fetch first x rows来限制结果
db2 "
SELECT PRICE.PRC_SECURITY_ID,
\(decimal\(PRICE.PRC_PRICE\)\),
PRICE.PRC_CURRENCY,PRICE.PRC_CURRENCY
FROM RISKAPP.PRICE as PRICE
inner join RISKAPP.SECURITY as SECURITY
on PRICE.PRC_SECURITY_ID = SECURITY.SEC_SECURITY_ID
and SECURITY.SEC_TYPE = "E"
AND SECURITY.SEC_MATURITY_DATE >='20141118'
AND PRICE.PRC_EXTRACT_PERIOD ='PBNS'
AND PRICE.PRC_LAST_UPDATE_TMS >= '2014-10-01'
fetch first 10 rows only"
如果上一个查询运行良好,您只需要在开头添加导出语句。
db2 export to prc_sec_01.txt of del
SELECT PRICE.PRC_SECURITY_ID,
...
根据@mustaccio的建议,最好将所有内容包含在引号中,而不是转义字符:
db2 "export to prc_sec_01.txt of del
SELECT PRICE.PRC_SECURITY_ID,
decimal(PRICE.PRC_PRICE),
PRICE.PRC_CURRENCY,PRICE.PRC_CURRENCY
FROM RISKAPP.PRICE as PRICE
inner join RISKAPP.SECURITY as SECURITY
on PRICE.PRC_SECURITY_ID = SECURITY.SEC_SECURITY_ID
and SECURITY.SEC_TYPE = "E"
AND SECURITY.SEC_MATURITY_DATE >='20141118'
AND PRICE.PRC_EXTRACT_PERIOD ='PBNS'
AND PRICE.PRC_LAST_UPDATE_TMS >= '2014-10-01'"