Ошибка ora 00917

SQL Error: ORA-00917: missing comma error occurs when a comma is missing in the VALUES clause of the Oracle insert statement. In the insert statement, a comma is used to separate a list of values enclosed by parenthesis. If the comma was missing, the insert statement could not identify all of the values in the VALUES clause. The insert statement will fail to store the values into the Oracle table. In this case, the error message SQL Error: ORA-00917: missing comma will be displayed.

The VALUES clause of the insert statement contains a list of column values to be stored in the table. The comma will be used to separate each value. The list of all values is enclosed by open and close parenthesis. The error message will be displayed if the comma is missing in the list of values where it is required. Oracle will validate the comma operator until it finds the close parentheses.If neither a comma operator nor a closing parenthesis is found in the VALUES clause of the insert statement, Oracle will throw an error SQL Error: ORA-00917: missing comma.

When the ORA-00917 error occur

If the comma operator and the close parenthesis are missing from the insert statement’s VALUES clause, the insert statement will fail to save the values in the database tables. In the insert statement, the comma operator is absent where it should be. If you create an insert statement without a comma and closing parenthesis in the VALUES clause, the error will occur.

Problem

insert into emp (id,name) values (1,2;

Error

Error starting at line : 36 in command -
insert into emp (id,name) values (1,2
Error at Command Line : 36 Column : 37
Error report -
SQL Error: ORA-00917: missing comma
00917. 00000 -  "missing comma"

Root Cause

The VALUES clause of the insert statement will be used to identify and save the list of values. The comma operator is used to separate each value. All of the values are surrounded by open and closed parenthesis. If neither the comma operator nor the close parenthesis are present in the list, the insert statement is unable to identify a list of all the values. The error message will be displayed in this scenario.

Solution 1

If neither the comma operator nor the close parenthesis are present in the list, the insert statement is unable to identify a list of all the values. Add the closing parenthesis if the list of values is complete. If the values are missing, add them by separating them using the comma operator. If the comma operator is missing between the values, insert it where it is required.

Problem

insert into emp (id,name) values (1,2;

SQL Error: ORA-00917: missing comma
00917. 00000 -  "missing comma"

Solution

insert into emp (id,name) values (1,2);

Solution 2

Single quotes should be used to surround the string and date values. If the single quotes in the insert statement are missing, the error message will be shown. The insert statement was unable to recognize the string and date value because the single quotation was missing. The insert statement failed to identify the closing parenthesis, hence the list of values could not be recognized.

Problem

insert into servers (id,name,ip) values (1,'production',192.168.0.1);

SQL Error: ORA-00917: missing comma
00917. 00000 -  "missing comma"

Solution

insert into servers (id,name,ip) values (1,'production','192.168.0.1');

Solution 3

If the database table contains unicode characters, the insert statements must appropriately handle the unicode characters. If there is a problem with the unicode characters, the insert statement should not be completed. Run the query below and confirm that the value is ‘AL32UTF8’. If this is not the case, the insert statement should be used in accordance with the unicode support.

select * from sys.props$ where name='NLS_CHARACTERSET';

Problem

insert into emp (id,name) values (1,'????');

Error

SQL Error: ORA-00917: missing comma
00917. 00000 -  "missing comma"

Solution 4

If you use the sequence value in the insert statement, be sure you use the correct syntax. Check if the sequence exists in the Oracle database. If a problem occurs while using database objects such as sequence, the “SQL Error:ORA-00917: missing comma” error may occur.

totn Oracle Error Messages


Learn the cause and how to resolve the ORA-00917 error message in Oracle.

Description

When you encounter an ORA-00917 error, the following error message will appear:

  • ORA-00917: missing comma

Cause

You tried to execute a statement, but you missed a required comma.

Resolution

The option(s) to resolve this Oracle error are:

Option #1

Try fixing the statement and re-executing.

If you need to check out the proper syntax for your SQL statement, you can view the following pages:

SELECT Statement
INSERT Statement
UPDATE Statement
DELETE Statement

Some other useful pages are:

IN Condition
UNION Query
UNION ALL Query
Subqueries
Joins

Doing some Oracle DBA homework and I’ve looked at several posts about the 00917 error, but I’m just doing a simple INSERT. I can’t seem to see where I’m missing a comma or a parenthesis. Any help?

INSERT INTO copy_f_orders 
(ORDER_NUMBER, TO_DATE(ORDER_DATE, 'mm-dd-RRRR'), ORDER_TOTAL, CUST_ID, STAFF_ID)
VALUES (5691, '09-23-2004', 145.98, 225, 12);

asked Oct 14, 2015 at 13:59

TheDoc's user avatar

0

Don’t use function call in column list:

INSERT INTO copy_f_orders(ORDER_NUMBER, ORDER_DATE, ORDER_TOTAL, CUST_ID, STAFF_ID)
VALUES (5691, '09-23-2004', 145.98, 225, 12);

If you need call it in values:

INSERT INTO copy_f_orders(ORDER_NUMBER, ORDER_DATE, ORDER_TOTAL, CUST_ID, STAFF_ID)
VALUES (5691, TO_DATE('09-23-2004', 'mm-dd-RRRR'), 145.98, 225, 12);

answered Oct 14, 2015 at 14:01

Lukasz Szozda's user avatar

Lukasz SzozdaLukasz Szozda

164k23 gold badges237 silver badges277 bronze badges

9

INSERT INTO copy_f_orders 
(ORDER_NUMBER, TO_DATE(ORDER_DATE, 'mm-dd-RRRR'), ORDER_TOTAL, CUST_ID, STAFF_ID)
VALUES (5691, '09-23-2004', 145.98, 225, 12);

It should be

INSERT INTO copy_f_orders 
(ORDER_NUMBER, ORDER_DATE, ORDER_TOTAL, CUST_ID, STAFF_ID)
VALUES (5691, TO_DATE('09-23-2004', 'mm-dd-RRRR'), 145.98, 225, 12);

No point using TO_DATE functions on columns, Hope it makes sense.

Boneist's user avatar

Boneist

22.9k1 gold badge25 silver badges40 bronze badges

answered Oct 14, 2015 at 14:05

Roy Paruchuri's user avatar

5

("INSERT INTO copy_f_orders 
(ORDER_NUMBER, TO_DATE(ORDER_DATE, 'mm-dd-RRRR'), ORDER_TOTAL, CUST_ID, STAFF_ID)
VALUES (5691, '09-23-2004', 145.98, 225, 12)");

Stefan Ferstl's user avatar

answered Dec 2, 2015 at 19:29

krishna bhagodikar's user avatar

1

May 6, 2021

I got ” ORA-00917 missing comma ”  error in Oracle database.

ORA-00917 missing comma

Details of error are as follows.

ORA-00917 missing comma

Cause: A required comma has been omitted from a list of columns or values in an INSERT statement or a list of the form ((C,D),(E,F), ...).

Action: Correct the syntax

missing comma

This ORA-00917 error is related with the required comma has been omitted from a list of columns or values in an INSERT statement or a list of the form ((C,D),(E,F), …).

To solve this error, Correct the syntax

Don’t forget using comma.

Sometimes  there is a missing ) at the end of Insert, you should add if one of ) is missing.

Do you want to learn Oracle Database for Beginners, then read the following articles.

Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

ORA-00917: missing comma

ORA-00917: missing comma

Cause:

A required comma has been omitted from a list of columns or values in an INSERT statement.

Solution:

Correct the syntax.

Example:

declare  
	v_sql varchar2(4000):='Insert into BOOKS (ID,NAME,PRICE) values ';  
	v_string varchar2(32000);
	i number:=3;
	v_id number:=5;
	v_name varchar2(200):='MySQL Tutorial';
	v_price number:=23;
begin  
	for i in 1..3 loop
		v_string:=v_sql||'('||v_id||','||v_name||v_price||');';
		execute immediate v_string;  
		v_id:=v_id+1;
	end loop;
end;  

Output:

ORA-00917: missing comma

Correct

declare  
	v_sql varchar2(4000):='Insert into BOOKS (ID,NAME,PRICE) values ';  
	v_string varchar2(32000);
	i number:=3;
	v_id number:=5;
	v_name varchar2(200):='MySQL Tutorial';
	v_price number:=23;
begin  
	for i in 1..3 loop
		v_string:=v_sql||'('||v_id||','''||v_name||''','||v_price||')';
		execute immediate v_string;  
		v_id:=v_id+1;
	end loop;
end; 

Output:

anonymous block completed

Понравилась статья? Поделить с друзьями:
  • Ошибка ora 00913
  • Ошибка ora 01019
  • Ошибка optifine 1282
  • Ошибка ora 00900
  • Ошибка jvcu 520428