当前位置:网站首页>Solutions to the error reported by executing Oracle SQL statement [ora-00904: "createtime": invalid identifier] and [ora-00913: too many values]
Solutions to the error reported by executing Oracle SQL statement [ora-00904: "createtime": invalid identifier] and [ora-00913: too many values]
2022-06-10 23:22:00 【Milk coffee 13】
One 、 Problem description
① Use navicat After the modeling tool establishes the table structure , export sql Statement or directly synchronize the model to the specified user mode , We use normal query statements to query the contents and report errors 【ORA-00904: "CREATETIME": Invalid identifier 】;
② Execute inserted sql Wrong sentence 【ORA-00913: Too many values 】;
Two 、 Problem analysis
2.1、ORA-00904: "CREATETIME": Invalid identifier
Let's check navicat The table creation statement exported by the modeling tool , It is found that the fields are all enclosed in double quotation marks ;
If we use sql Statements such as 【SELECT CreateTime FROM "IQC_MaterialStandard_Record"】, The following error will be reported :
| Serial number | explain | |
| 1 | stay Oracle The middle double quotation marks are used to : 1、【 If you create an object , Object name 、 Field names are enclosed in double quotes , said Oracle Will be strictly case sensitive 】; 2、【 otherwise Oracle All default uppercase 】 | |
| 2 | Single quotation marks indicate : A single quoted field is a word similar to a string , Not case sensitive . Single quotation marks are used to identify the difference between characters and numbers ; When specifying string text , You must enclose the string text in single quotes . | |
| 3 | Double quotation marks are used for 【 keyword 、 Object name 、 Field name 、 Alias 】 | |
2.2、ORA-00913: Too many values
View our sql sentence 【
INSERT INTO "IQC_MaterialStandard_Record"("Id","InspectionLot","MaterialType") VALUES('100010','3002004101',' spare part ','2022-06-10 13:29:36')】, After careful inspection, it is found that there are more data to be inserted than fields , Match errors that are not reported .

3、 ... and 、 resolvent
3.1、 solve ORA-00904: "XXX Field ": Invalid identifier
Method 1 : Add double quotes to the fields in the query
// The original error reporting statement
SELECT CreateTime FROM "IQC_MaterialStandard_Record"
// Statements that can be executed normally after modification ( You need to add double quotes to the field )
SELECT "CreateTime" FROM "IQC_MaterialStandard_Record" /// <summary>
/// Concatenate all elements of a string array , Where the specified separator is used between each element , Add the specified identifier on both sides of each element .
/// </summary>
/// <param name="separator"> Separator ( For example, comma 【","】)</param>
/// <param name="fieldContainMark"> The identifier contained on both sides of the field ( For example, the field contains double quotation marks 【"\""】)</param>
/// <param name="values"> Array to concatenate </param>
/// <returns> Returns the contents of a concatenated string </returns>
public static string Join(String separator,string fieldContainMark, params string[] values)
{
if (string.IsNullOrEmpty(separator) || values == null || values.Length <= 0) return null;
string str = string.Empty;
int len = values.Length;
if (!string.IsNullOrEmpty(fieldContainMark))
{
for (int i = 0; i < len - 1; i++)
{
str += $"{fieldContainMark}{values[i]}{fieldContainMark}{separator}";
}
str += $"{fieldContainMark}{values[len - 1]}{fieldContainMark}";
}
else
{
for (int i = 0; i < len - 1; i++)
{
str += $"{values[i]}{separator}";
}
str += $"{values[len - 1]}";
}
return str;
} // Get the attribute name of the specified model
var props = typeof(MaterialModel).GetProperties().Select(x => x.Name).ToArray();
// Assembly insert sql( Get the model attribute as the field name and the array with double quotation marks )
string cols = EntityHelper.Join(",","\"",props);Method 2 : Recreate the table , Remove the double quotes from the field

You can also use other editing tools to replace sql Double quotation marks in statements , And then execute sql Statement after the table is recreated, the previous statement can be executed normally .
3.2、 solve ORA-00913: Too many values
Check sql Statement found that the filled value is more than the specified field content , Just add the corresponding field or delete more than values , as follows :
// The original mistake sql sentence
INSERT INTO "IQC_MaterialStandard_Record"("Id","InspectionLot","MaterialType") VALUES('100010','3002004101',' spare part ','2022-06-10 13:29:36')
// Now the correct sql sentence ( Whether you need to add fields or delete data needs to be viewed according to the table fields you have created )
INSERT INTO "IQC_MaterialStandard_Record"("Id","InspectionLot","MaterialType","CreateTime") VALUES('100010','3002004101',' spare part ','2022-06-10 13:29:36')边栏推荐
- Flowable BPMN相关知识
- 项目实训10——对特定数据库的备份
- [QPSK if] Verilog design of QPSK IF signal generation module based on FPGA
- PwnTheBox,Web:hello
- Electronic Society C language level 1 7. Draw rectangle
- 34. 在排序数组中查找元素的第一个和最后一个位置-二分查找、双指针
- Executor - Shutdown、ShutdownNow、awaitTermination 詳解與實戰
- PwnTheBox,Web:hello
- Example analysis of SQL query optimization principle
- 电子协会 C语言 1级 7 、画矩形
猜你喜欢

一 组工人合作完成某一部件的装配工序所需的时间(单位:分钟)分别如下:

样板小作坊

乘风破浪,探索数据可视化开发平台 FlyFish 开源背后的秘密!

2022最新软件测试面试题常问的30道【持续更新~】

IP anti query domain name

Exécuteur - shutdown, shutdown Now, awaittermination details and actual Fighting

JS sensitive information leak detection tool

Ride the storm and explore the secret behind the open source of flyfish, a data visualization development platform!

项目实训11——对数据库的定时备份
![[论文分享] PATA: Fuzzing with Path Aware Taint Analysis](/img/f6/627344c5da588afcf70302ef29d134.png)
[论文分享] PATA: Fuzzing with Path Aware Taint Analysis
随机推荐
【QPSK中频】基于FPGA的QPSK中频信号产生模块verilog设计
Sentinel
Vulnhub's DC3
聚簇索引和非聚簇索引
R 语言绘制二维正态分布的密度曲面图;
06151020 mysterious code, waiting for you to decipher
【Flutter 问题系列第 6 篇】如何在 Flutter 中实现列表消息的滚动效果
完美解码PureCodec 20220601
MySQL相关-0416
Halcon combined with C # to detect surface defects -- affine transformation (II)
Sdn/nfv application in cloud data center
视频融合云服务EasyCVR集群录像事件查询无效是什么原因?
Is it safe to open a BOC securities account? Is the risk high?
关于嵌入式音频开发需要注意的两个方面
Executor - Shutdown、ShutdownNow、awaitTermination 详解与实战
一 组工人合作完成某一部件的装配工序所需的时间(单位:分钟)分别如下:
上海股票开户是安全的吗?
0223 summary
【接口教程】EasyCVR如何通过接口设置平台级联?
Optimize code to remove if else