获取ORA-00936:在以下查询中缺少表达式。 请帮忙。
INSERT INTO TT_FX_LADDER_INFO(DEAL_NUM,SPOT_RATE,FORWARD_RATE,LBS_RATE,DF_CCY1,DF_CCY2,FX_TYPE,TYPE,TRADING_BOOK_FBO_ID_NUM,ENTITY_FBO_ID_NUM,POS_CCY_PAIR,AS_ON_DATE,DECOMPOSE_DATE,CCY_ONE_AMOUNT,CCY_TWO_AMOUNT,CCY_1,CCY_2,IS_FX_MERCHANT_TRADE) VALUES
(
SELECT '0','0','0','0','0','0','FWD','OPENING POSITION',TRADING_BOOK_FBO_ID_NUM,ENTITY_FBO_ID_NUM,CURRENCY_PAIR,LADDER_DATE,DECOMPOSE_DATE,SUM(CCY_ONE_AMOUNT) CCY_ONE_POSITION,SUM(CCY_TWO_AMOUNT) CCY_TWO_POSITION,CCY_1,CCY_2,IS_FX_MERCHANT_TRADE
FROM
(
SELECT hdg.TRADING_BOOK_FBO_ID_NUM TRADING_BOOK_FBO_ID_NUM,hdg.ENTITY_FBO_ID_NUM,hdg.CURRENCY_PAIR,
TO_CHAR(elem.LADDER_DATE,'DD-MM-YYYY') LADDER_DATE,
TO_CHAR(elem.LADDER_DATE,'DD-MM-YYYY') DECOMPOSE_DATE
FROM TT_FX_HDG hdg,TT_FX_HDG_ELEMS elem
WHERE elem.DEAL_NUM = hdg.DEAL_NUM
AND hdg.FX_TYPE = 'FWD'
)
group by TRADING_BOOK_FBO_ID_NUM,ENTITY_FBO_ID_NUM,CURRENCY_PAIR,LADDER_DATE,DECOMPOSE_DATE,CCY_1,CCY_2,IS_FX_MERCHANT_TRADE
);
没有insert into子句的内部查询工作正常。
非常感谢帮助。
答案 0 :(得分:0)
只需删除values
即可。使用insert . . . select
时无需任何操作。所以,假设其他一切都排好了:
INSERT INTO TT_FX_LADDER_INFO(DEAL_NUM, SPOT_RATE,FORWARD_RATE,LBS_RATE,DF_CCY1,DF_CCY2,FX_TYPE,TYPE,TRADING_BOOK_FBO_ID_NUM,ENTITY_FBO_ID_NUM,POS_CCY_PAIR,AS_ON_DATE,DECOMPOSE_DATE,CCY_ONE_AMOUNT,CCY_TWO_AMOUNT,CCY_1,CCY_2,IS_FX_MERCHANT_TRADE
)
SELECT '0','0','0','0','0','0', 'FWD', 'OPENING POSITION',
TRADING_BOOK_FBO_ID_NUM, ENTITY_FBO_ID_NUM, CURRENCY_PAIR,
LADDER_DATE, DECOMPOSE_DATE,
SUM(CCY_ONE_AMOUNT) as CCY_ONE_POSITION,
SUM(CCY_TWO_AMOUNT) as CCY_TWO_POSITION,
CCY_1,CCY_2,IS_FX_MERCHANT_TRADE
FROM (SELECT hdg.TRADING_BOOK_FBO_ID_NUM TRADING_BOOK_FBO_ID_NUM, hdg.ENTITY_FBO_ID_NUM, hdg.CURRENCY_PAIR,
TO_CHAR(elem.LADDER_DATE,'DD-MM-YYYY') as LADDER_DATE,
TO_CHAR(elem.LADDER_DATE,'DD-MM-YYYY') as DECOMPOSE_DATE
FROM TT_FX_HDG hdg JOIN
TT_FX_HDG_ELEMS elem
ON elem.DEAL_NUM = hdg.DEAL_NUM AND hdg.FX_TYPE = 'FWD'
) x
GROUP BY TRADING_BOOK_FBO_ID_NUM, ENTITY_FBO_ID_NUM, CURRENCY_PAIR,
LADDER_DATE, DECOMPOSE_DATE, CCY_1,CCY_2,
IS_FX_MERCHANT_TRADE;
我还建议:
JOIN
语法。简单规则:从不在FROM
子句中使用逗号。as
。答案 1 :(得分:0)
您的查询完全错误。发现一些错误。
SUM(CCY_ONE_AMOUNT) CCY_ONE_POSITION,SUM(CCY_TWO_AMOUNT) CCY_TWO_POSITION,CCY_1,CCY_2,IS_FX_MERCHANT_TRADE
在内部select语句中未选择上面的列。因此它不会起作用。