ORA-00904:“可能”:无效的标识符

发布于 2024-11-29 01:11:26 字数 690 浏览 1 评论 0原文

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_TRANSACTION 
WHERE    
TRANSACTION_DATE = to_char(02-MAY-2006, 'dd/mm/yyyy')

上面是我在 ORACLE 中输入的查询,但它给了我错误 ORA-00904:"MAY":INVALID IDENTIFIER 任何人都可以帮我解决这个问题吗?谢谢

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_TRANSACTION 
WHERE    
TRANSACTION_DATE = to_char(02-MAY-2006, 'dd/mm/yyyy')

The above is the query which I am entering in ORACLE but it is giving me the error ORA-00904:"MAY":INVALID IDENTIFIER
Can anyone help me with this please. Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

水晶透心 2024-12-06 01:11:26

如果 TRANSACTION_DATE 是一个日期(我真诚地希望它是),则需要使用 TO_DATE 将字符串转换为 DATE。因为它是一个字符串,所以需要用引号引起来,因为这就是我们对文字所做的处理。

哦,另一件事是,掩码需要与字符串中用于表示日期的格式匹配。

所以,该行应该是:

TRANSACTION_DATE = to_date('02-MAY-2006', 'dd-mon-yyyy')

If TRANSACTION_DATE is a date (and I sincerely hope it is) you need to use TO_DATE to convert a string into a DATE. And because it's a string it needs to be in quotes, because that's what we do with literals.

Oh, and the other thing is, the mask needs to match the format used in the string to represent the date.

So, the line should be:

TRANSACTION_DATE = to_date('02-MAY-2006', 'dd-mon-yyyy')
捎一片雪花 2024-12-06 01:11:26

您需要在 2006 年 5 月 2 日左右添加引号,否则看起来像算术表达式。

You need to add quotes around 02-MAY-2006, otherwise that looks like an arithmetic expression.

早茶月光 2024-12-06 01:11:26
TRANSACTION_DATE = to_char('02-MAY-2006', 'dd/mm/yyyy')

将其放在引号中,否则它将被解释为标识符,而不是文字。

TRANSACTION_DATE = to_char('02-MAY-2006', 'dd/mm/yyyy')

Put it in quotes, otherwise it is interpeted as an identifier, not a literal.

最近可好 2024-12-06 01:11:26

如果您必须使用字符串

要重新格式化,您必须首先将其转换为日期,然后转换为您想要的格式,例如:

TRANSACTION_DATE = TO_CHAR(TO_DATE('02-MAY-2006'),'dd/mm/yyyy')

简单地尝试将其重新格式化为 dd/mm/yyyy 是行不通的

if you must use a string

To reformat you must first convert it to a date, and then to the format you desire e.g:

TRANSACTION_DATE = TO_CHAR(TO_DATE('02-MAY-2006'),'dd/mm/yyyy')

simply trying to reformat it as dd/mm/yyyy will not work

风筝在阴天搁浅。 2024-12-06 01:11:26

使用 WHERE TRANSACTION_DATE = to_date('02-MAY-2006', 'dd-MON-yyyy') 而不是 WHERE TRANSACTION_DATE = to_char(02-MAY-2006, 'dd/mm/ yyyy')

Use WHERE TRANSACTION_DATE = to_date('02-MAY-2006', 'dd-MON-yyyy') instead of WHERE TRANSACTION_DATE = to_char(02-MAY-2006, 'dd/mm/yyyy')

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文