1. How many transactions are shown in the following code? Explain your reasoning.
BEGIN
INSERT INTO my_savings (account_id, amount)
VALUES (10377, 200);
INSERT INTO my_checking (account_id, amount)
VALUES (10378, 100);
END;
2
2. Create the endangered species table by running the following statement in Application Express:
CREATE TABLE endangered_species
(species_id NUMBER(4) CONSTRAINT es_spec_pk PRIMARY KEY, common_name VARCHAR2(30) CONSTRAINT es_com_name_nn NOT NULL, scientific_name VARCHAR2(30) CONSTRAINT es_sci_name_nn NOT NULL);
3. Examine the following block of code. If you were to run this block, what data do you think would be saved in the database?
BEGIN
INSERT INTO endangered_species
VALUES (100, ‘Polar Bear’, ‘Ursus maritimus’);
SAVEPOINT sp_100;
INSERT INTO endangered_species
VALUES (200, ‘Spotted Owl’, ‘Strix occidentalis’);
SAVEPOINT sp_200;
INSERT INTO endangered_species
VALUES (300, ‘Asiatic Black Bear’, ‘Ursus thibetanus’);
ROLLBACK TO sp_100;
COMMIT;
END;
3
4. Run the block above to test your theory. Confirm your projected data was added.
5. Examine the following block. If you were to run this block, what data do you think would be saved in the database? Run the block to test your theory.
.
BEGIN
INSERT INTO endangered_species
VALUES (400, ‘Blue Gound Beetle’, ‘Carabus intricatus’);
SAVEPOINT sp_400;
INSERT INTO endangered_species
VALUES (500, ‘Little Spotted Cat’, ‘Leopardus tigrinus’);
ROLLBACK;
INSERT INTO endangered_species
VALUES (600, ‘Veined Tongue-Fern’, ‘Elaphoglossum nervosum’);
ROLLBACK TO sp_400;
END;