drop table if exists employees
ORA-00933: SQL command not properly endedMore Details: https://docs.oracle.com/error-help/db/ora-00933
CREATE TABLE employees (
emp_id NUMBER PRIMARY KEY,
emp_name VARCHAR2(100)
)
Table created.
INSERT INTO employees (emp_id, emp_name) VALUES (1, 'John Doe')
1 row(s) inserted.
INSERT INTO employees (emp_id, emp_name) VALUES (2, 'Jane Smith')
1 row(s) inserted.
INSERT INTO employees (emp_id, emp_name) VALUES (3, 'Robert Johnson')
1 row(s) inserted.
COMMIT
Statement processed.
BEGIN
-- Insert the first record
INSERT INTO employees (emp_id, emp_name) VALUES (4, 'John');
-- Create a Savepoint after the first record insertion
SAVEPOINT sp_insert_record1;
-- Check if the Savepoint sp_insert_record1 exists
-- IF DBMS_TRANSACTION.SAVEPOINT_EXISTS('sp_insert_record1') = 1 THEN
DBMS_OUTPUT.PUT_LINE('Savepoint sp_insert_record1 exists.');
-- ELSE
-- DBMS_OUTPUT.PUT_LINE('Savepoint sp_insert_record1 does not exist.');
-- END IF;
-- Insert the second record
INSERT INTO employees (emp_id, emp_name) VALUES (5, 'Jane');
-- Create a Savepoint after the second record insertion
SAVEPOINT sp_insert_record2;
DBMS_OUTPUT.PUT_LINE('Savepoint sp_insert_record2 exists.');
-- Insert the third record
INSERT INTO employees (emp_id, emp_name) VALUES (6, 'Robert');
-- DBMS_OUTPUT.PUT_LINE(10/0);
-- Commit the transaction to save all changes
COMMIT;
EXCEPTION
WHEN OTHERS THEN
-- Roll back to the first Savepoint (sp_insert_record1) if an error occurs
ROLLBACK TO SAVEPOINT sp_insert_record1;
DBMS_OUTPUT.PUT_LINE('Error occurred. Rolled back to the first Savepoint.');
RAISE; -- Reraise the exception to the caller
END;
Statement processed.
Savepoint sp_insert_record1 exists.
Savepoint sp_insert_record2 exists.
drop table if exists employees
ORA-00933: SQL command not properly endedMore Details: https://docs.oracle.com/error-help/db/ora-00933
CREATE TABLE employees (
emp_id NUMBER PRIMARY KEY,
emp_name VARCHAR2(100)
)
ORA-00955: name is already used by an existing objectMore Details: https://docs.oracle.com/error-help/db/ora-00955
INSERT INTO employees (emp_id, emp_name) VALUES (1, 'John Doe')
ORA-00001: unique constraint (SQL_OZWLTEJIJIZSHCNWIGKWLDBCI.SYS_C00129059297) violated ORA-06512: at "SYS.DBMS_SQL", line 1721More Details: https://docs.oracle.com/error-help/db/ora-00001
INSERT INTO employees (emp_id, emp_name) VALUES (2, 'Jane Smith')
ORA-00001: unique constraint (SQL_OZWLTEJIJIZSHCNWIGKWLDBCI.SYS_C00129059297) violated ORA-06512: at "SYS.DBMS_SQL", line 1721More Details: https://docs.oracle.com/error-help/db/ora-00001
INSERT INTO employees (emp_id, emp_name) VALUES (3, 'Robert Johnson')
ORA-00001: unique constraint (SQL_OZWLTEJIJIZSHCNWIGKWLDBCI.SYS_C00129059297) violated ORA-06512: at "SYS.DBMS_SQL", line 1721More Details: https://docs.oracle.com/error-help/db/ora-00001
COMMIT
Statement processed.
BEGIN
-- Insert the first record
INSERT INTO employees (emp_id, emp_name) VALUES (4, 'John');
-- Create a Savepoint after the first record insertion
SAVEPOINT sp_insert_record1;
-- Check if the Savepoint sp_insert_record1 exists
-- IF DBMS_TRANSACTION.SAVEPOINT_EXISTS('sp_insert_record1') = 1 THEN
DBMS_OUTPUT.PUT_LINE('Savepoint sp_insert_record1 exists.');
-- ELSE
-- DBMS_OUTPUT.PUT_LINE('Savepoint sp_insert_record1 does not exist.');
-- END IF;
-- Insert the second record
INSERT INTO employees (emp_id, emp_name) VALUES (5, 'Jane');
-- Create a Savepoint after the second record insertion
SAVEPOINT sp_insert_record2;
DBMS_OUTPUT.PUT_LINE('Savepoint sp_insert_record2 exists.');
-- Insert the third record
INSERT INTO employees (emp_id, emp_name) VALUES (6, 'Robert');
DBMS_OUTPUT.PUT_LINE(10/0);
-- Commit the transaction to save all changes
COMMIT;
EXCEPTION
WHEN OTHERS THEN
-- Roll back to the first Savepoint (sp_insert_record1) if an error occurs
ROLLBACK TO SAVEPOINT sp_insert_record1;
DBMS_OUTPUT.PUT_LINE('Error occurred. Rolled back to the first Savepoint.');
RAISE; -- Reraise the exception to the caller
END;
ORA-01086: savepoint 'SP_INSERT_RECORD1' never established in this session or is invalid ORA-06512: at line 32 ORA-06512: at line 3 ORA-06512: at "SYS.DBMS_SQL", line 1721More Details: https://docs.oracle.com/error-help/db/ora-01086