INSERT INTO FCR.TRANSACTION (TRX_UNIT, TRX_DATE, TRX_USR,
TRX_USR_SN, TRANSACTION_CODE,
PRODUCT_CODE, CURRENCY_SHORT_DESCRIPTION,
AMOUNT_FC, EXCHANGE_RATE, AMOUNT_DC)
SELECT SOURCE_SYSTEM_CHANNEL_CODE, to_char(TRANSACTION_DATE), 'dd/mm/yyyy'),
USER_CODE, USER_TRANSACTION_SERIAL_NUMBER, TRANSACTION_CODE,
PROFITS_PRODUCT_CODE, SHORT_DESCRIPTION, SOURCE_AMOUNT_FC,
SOURCE_EXCHANGE_RATE, SOURCE_AMOUNT_EUR
FROM FCR.ORION_FCR_TRANSACTION
WHERE TRANSACTION_DATE = 'to_char(" + date + ", 'dd/mm/yyyy')'
以上查询给了我ORA-00923 ERROR. FROM KEYWORD NOT FOUND IN POSITION.
任何人都可以帮我解决上述问题。
我认为该错误与我的C#代码中的行有关:
WHERE TRANSACTION_DATE = 'to_char(" + date + ", 'dd/mm/yyyy')'
答案 0 :(得分:3)
这是因为在TRANSACTION_DATE之后的右括号。
事实上,将to_char放在字符串中的WHERE中也无济于事。 :)
我不确定,但如果你只使用一些缩进,它可能会有所帮助。如果您的查询以更易读的方式概述,那么更容易发现像这样的拼写错误。
INSERT INTO FCR.TRANSACTION (
TRX_UNIT,
TRX_DATE,
TRX_USR,
TRX_USR_SN,
TRANSACTION_CODE,
PRODUCT_CODE,
CURRENCY_SHORT_DESCRIPTION,
AMOUNT_FC,
EXCHANGE_RATE,
AMOUNT_DC)
SELECT
SOURCE_SYSTEM_CHANNEL_CODE,
to_char(TRANSACTION_DATE), 'dd/mm/yyyy'),
USER_CODE,
USER_TRANSACTION_SERIAL_NUMBER,
TRANSACTION_CODE,
PROFITS_PRODUCT_CODE,
SHORT_DESCRIPTION,
SOURCE_AMOUNT_FC,
SOURCE_EXCHANGE_RATE,
SOURCE_AMOUNT_EUR
FROM
FCR.ORION_FCR_TRANSACTION
WHERE
TRANSACTION_DATE = 'to_char(" + date + ", 'dd/mm/yyyy')'
答案 1 :(得分:3)
我猜这个:
to_char(TRANSACTION_DATE), 'dd/mm/yyyy'),
应该是这样的:
to_char(TRANSACTION_DATE, 'dd/mm/yyyy'),
和此:
WHERE TRANSACTION_DATE = 'to_char(" + date + ", 'dd/mm/yyyy')'
应该是这样的:
WHERE TRANSACTION_DATE = to_char(date, 'dd/mm/yyyy')'
答案 2 :(得分:2)
格式化后使其更清晰,似乎您在选择部分
中添加了a)您有SELECT SOURCE_SYSTEM_CHANNEL_CODE, to_char(TRANSACTION_DATE), 'dd/mm/yyyy'),
我认为你在TRANSACTION_DATE之后为to_char添加了一个额外的结束括号
SELECT SOURCE_SYSTEM_CHANNEL_CODE, to_char(TRANSACTION_DATE, 'dd/mm/yyyy'),
有助于清楚地格式化代码并使用与括号匹配的编辑器。