PL/SQL Control Statement Exercises: Insert a row if the featched value for a component is specified
PL/SQL Control Statement: Exercise-30 with Solution
Write a program in PL/SQL to insert a row if the featched value for a component is specified.
DROP TABLE TEST; CREATE TABLE TEST( c1 INTEGER, c2 INTEGER); DELETE FROM TEST; INSERT INTO TEST VALUES(2, 4); INSERT INTO TEST VALUES(1, 3); DECLARE n1 NUMBER; n2 NUMBER; BEGIN SELECT c1,c2 INTO n1,n2 FROM TEST WHERE c1>1; IF n2=4 THEN INSERT INTO TEST VALUES(n2,n1); ELSE INSERT INTO TEST VALUES(n2+15,n1+15); END IF; END; /
PL/SQL procedure successfully completed. To see the inserted row use the command "select * from test;"
Improve this sample solution and post your code through Disqus
What is the difficulty level of this exercise?
- New Content published on w3resource:
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- 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