Skip to main content
edited tags
Link
user330315
user330315
Source Link
jane Doe
  • 157
  • 2
  • 2
  • 9

variable inside execute immediate

I am using the following Procedure in pl sql

CREATE OR REPLACE "MY_PROCEDURE" (v_id number, v_name varchar2) AS
     BEGIN
        EXECUTE IMMEDIATE ' CREATE TABLE T_TEMPO ( t_id number , t_name varchar2(250) , t_value number )';
        EXECUTE IMMEDIATE 'INSERT INTO T_TEMPO (t_id , t_name, t_value)
                           SELECT id , name , value
                           from TABLE_2
                           where TABLE_2.id = || v_id ||
                           AND TABLE_2.name = || v_name || ';

But this doesn't work I have a missing expression error, I wonder it can't evaluate the value of the variables v_id and v_name inside the execute immediate. Can anyone help please?