0

Well I have an dynamic variable

private_table_name VARCHAR2(100) := 'test';

test is the name of the table.

Now I want to insert into the table with this satatement.

INSERT INTO private_table_name VALUES (employee_rec.employee_id, concaternate_employee_name(employee_rec.employee_id), employee_rec.salary * 1.10);

1 Answer 1

1

It is dynamic SQL you should use. For example:

SQL> CREATE TABLE test
  2  (
  3     price   NUMBER
  4  );

Table created.

SQL> DECLARE
  2     private_table_name  VARCHAR2 (100) := 'test';
  3  BEGIN
  4     EXECUTE IMMEDIATE   'insert into '
  5                      || private_table_name
  6                      || ' (price) values (50)';
  7  END;
  8  /

PL/SQL procedure successfully completed.

SQL> SELECT * FROM test;

     PRICE
----------
        50

SQL>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.