ORA-00933: SQL command not properly ended

ORA-00933: SQL command not properly ended

ORA-00933: SQL command not properly ended

Cause:

The SQL statement ends with an inappropriate clause.

Solution:

Correct the syntax by removing the inappropriate clauses.

Example:

declare  
	v_sql varchar2(4000):='Insert into BOOKS (ID,NAME,PRICE) values ';  
	v_string varchar2(32000);
	v_id number:=5;
	v_name varchar2(200):='SQL Tutorial';
	v_price number:=14;
begin  
	v_string:=v_sql||'('||v_id||',''||v_name||'','||v_price||');';  
	DBMS_OUTPUT.PUT_LINE(v_string);
	execute immediate v_string;  
end;  

Output:

ORA-00933: SQL command not properly ended
Insert into BOOKS (ID,NAME,PRICE) values (5,’||v_name||’,14);

Correct

declare  
	v_sql varchar2(4000):='Insert into BOOKS (ID,NAME,PRICE) values ';  
	v_string varchar2(32000);
	v_id number:=5;
	v_name varchar2(200):='SQL Tutorial';
	v_price number:=14;
begin  
	v_string:=v_sql||'('||v_id||','''||v_name||''','||v_price||')'; 
	DBMS_OUTPUT.PUT_LINE(v_string);
	execute immediate v_string;  
end;  

Output:

anonymous block completed
Insert into BOOKS (ID,NAME,PRICE) values (5,’SQL Tutorial’,14)