Skip to main content
added 623 characters in body
Source Link
Jorge Campos
  • 23.8k
  • 7
  • 65
  • 95

As you are creating a dynamic insert command you have to create it as is. So you are missing the single quotes for the value that is varchar:

execute immediate 
     'insert into create_tmp_table'||a|| ' values ('''|| b ||''');'; 
                                                    ^here     ^and here

And a good suggestion for this type of error is to do some debug. On your case you could create a varchar2 variable and put your insert on it then you use the dbms_output.put_line to this variable. Then you will have your sql command that you can test direct on your database. Something like:

declare
   sqlCommand varchar2(1000);
   --define a and b
begin
   --put some values in a and b
   sqlCommand := 'insert into create_tmp_table'||a|| ' values ('''|| b ||''');';
   dbms_output.put_line(sqlCommand);
end;

Then you will know what is wrong with the dynamic command.

As you are creating a dynamic insert command you have to create it as is. So you are missing the single quotes for the value that is varchar:

execute immediate 
     'insert into create_tmp_table'||a|| ' values ('''|| b ||''');'; 
                                                    ^here     ^and here

As you are creating a dynamic insert command you have to create it as is. So you are missing the single quotes for the value that is varchar:

execute immediate 
     'insert into create_tmp_table'||a|| ' values ('''|| b ||''');'; 
                                                    ^here     ^and here

And a good suggestion for this type of error is to do some debug. On your case you could create a varchar2 variable and put your insert on it then you use the dbms_output.put_line to this variable. Then you will have your sql command that you can test direct on your database. Something like:

declare
   sqlCommand varchar2(1000);
   --define a and b
begin
   --put some values in a and b
   sqlCommand := 'insert into create_tmp_table'||a|| ' values ('''|| b ||''');';
   dbms_output.put_line(sqlCommand);
end;

Then you will know what is wrong with the dynamic command.

Source Link
Jorge Campos
  • 23.8k
  • 7
  • 65
  • 95

As you are creating a dynamic insert command you have to create it as is. So you are missing the single quotes for the value that is varchar:

execute immediate 
     'insert into create_tmp_table'||a|| ' values ('''|| b ||''');'; 
                                                    ^here     ^and here