Skip to main content

Setting up for exercise

Refer to the details here and get the setup ready before testing the samples

Instructions

Topic: Diagnosing and Fixing Common SQL Errors Instructions: For each case, find the SQLCODE it generate, explain what caused the error, and suggest how to fix it.


INSERT INTO EMP (EMP_ID, NAME, DEPARTMENT, PHONE, SALARY)
VALUES (100, 'TOM', 'IT', '1234567890', 75000);

-- Run again with same EMP_ID
INSERT INTO EMP (EMP_ID, NAME, DEPARTMENT, PHONE, SALARY)
VALUES (100, 'JANE', 'HR', '9876543210', 80000);

INSERT INTO MENTOR (EMP_ID, SKILLS)
VALUES (9999, 'DB2');

INSERT INTO EMP (EMP_ID, NAME, DEPARTMENT, PHONE, SALARY)
VALUES (105, NULL, 'SALES', '9999999999', 68000);

SELECT * FROM EMPLOYEE_TABLE;

SELECT EMP_ID, FULLNAME FROM EMP;

INSERT INTO EMP_PUBLIC_DIRECTORY (EMP_ID, NAME, DEPARTMENT)
VALUES (201, 'ANU', 'SALES');

INSERT INTO EMP (EMP_ID, NAME, DEPARTMENT, PHONE, SALARY)
VALUES (106, 'JOHN', 'OPS', 'TOOLONGPHONE123', 72000);

SELECT EMP_ID FROM EMP E, MENTOR M
WHERE EMP_ID = EMP_ID;

SELECT DISTINCT NAME FROM EMP
ORDER BY SALARY;

UPDATE DEPT_SALARY_SUMMARY
SET AVERAGE_SALARY = 95000
WHERE DEPARTMENT = 'IT';