ORA-00917: missing comma

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