PL/SQL Control Statement Exercises: Insert records from one table to another
PL/SQL Control Statement: Exercise-29 with Solution
Write a program in PL/SQL to insert records from one table to another.
DROP TABLE emp_temp; CREATE TABLE emp_temp ( emp_id NUMBER, emp_email VARCHAR2(40) ); DECLARE number_of_emp NUMBER; BEGIN SELECT COUNT(employee_id) INTO number_of_emp FROM employees; FOR i IN 1..number_of_emp LOOP INSERT INTO emp_temp (emp_id, emp_email) VALUES(i, 'not available now'); END LOOP; END; /
PL/SQL procedure successfully completed. If you execute the command "select * from emp_temp;" you will see the data of emp_temp table.
Improve this sample solution and post your code through Disqus
Previous: Write a program in PL/SQL to check whether a number is prime or not using goto statement with for loop.
Next: Write a program in PL/SQL to insert a row if the featched value for a component is specified.
What is the difficulty level of this exercise?
- New Content published on w3resource :
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework