当前位置:网站首页>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')边栏推荐
猜你喜欢

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

功能测试之设计语言测试:功能测试包含哪些测试?分别有什么作用

考研英语词汇 unit1

SQL查询优化原理实例分析

Design language testing for functional testing: what tests are included in functional testing? What is the role of each

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

Dell R730 raid5 安装Server 2016(解决磁盘大于2T)
![[Video] kmeans mean clustering and hierarchical clustering: R language analysis life happiness index visualization | data sharing](/img/d5/d544ab0c14ba22946219feafdc3392.png)
[Video] kmeans mean clustering and hierarchical clustering: R language analysis life happiness index visualization | data sharing

Data and information resource sharing platform (IV)

Project training 10 - backup of specific databases
随机推荐
[Interface tutorial] how does easycvr set platform cascading through the interface?
Assembly: assembly mixed with c-faction language and corresponding lldb common instructions
Ribbon load balancing policy
Software features and functions of the blind box mall app system development
期货开户有什么限制嘛?哪里最安全?
优化代码去除if-else
云图说|每个成功的业务系统都离不开APIG的保驾护航
Which securities company does qiniu's securities belong to? Is it safe?
Commonplace - the timetable of the great philosopher Kant
Kotlin语言现在怎么不火了?
Clustered and non clustered indexes
PwnTheBox,Pwn:tutorial1
Dell R730 raid5 安装Server 2016(解决磁盘大于2T)
About string format(String format, Object... args)
LeetCode+ 21 - 25
34. 在排序数组中查找元素的第一个和最后一个位置-二分查找、双指针
OpenVP*整合ldap認證
IP anti query domain name
Project training 13 - Interface supplement
【sql语句基础】——增(insert)