SELECT
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLOYEE
END-EXEC.
01 S-CODE PIC S9(3) SIGN LEADING SEPARATE.
PROCEDURE DIVISION.
EXEC SQL
SELECT EMPNO, SALARY INTO :EMPNO, :SALARY
FROM TECH202.EMPLOYEES
WHERE EMPNO = "E001"
END-EXEC.
MOVE SQLCODE TO S-CODE.
DISPLAY 'ENO=' EMPNO.
DISPLAY 'SALARY=' SALARY.
DISPLAY S-CODE.
STOP RUN.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLOYEE
END-EXEC.
01 S-CODE PIC S9(3) SIGN LEADING SEPARATE.
PROCEDURE DIVISION.
EXEC SQL
SELECT EMPNO, SALARY INTO :EMPNO, :SALARY
FROM TECH202.EMPLOYEES
WHERE EMPNO = "E001"
END-EXEC.
MOVE SQLCODE TO S-CODE.
DISPLAY 'ENO=' EMPNO.
DISPLAY 'SALARY=' SALARY.
DISPLAY S-CODE.
STOP RUN.
--------------------------------------------------------------------
INSERT
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLOYEE
END-EXEC.
01 S-CODE PIC S9(3) SIGN LEADING SEPARATE.
01 WS-SAL PIC 9(6).
PROCEDURE DIVISION.
* EXEC SQL
* INSERT INTO TECH202.EMPLOYEES VALUES
* ("E002", "RAJA", "D001", 10000)
* END-EXEC.
ACCEPT EMPNO.
ACCEPT ENAME.
ACCEPT DEPTNO.
ACCEPT WS-SAL.
MOVE WS-SAL TO SALARY.
EXEC SQL
INSERT INTO TECH202.EMPLOYEES VALUES
(:EMPNO, :ENAME, :DEPTNO, :SALARY)
END-EXEC.
MOVE SQLCODE TO S-CODE.
DISPLAY S-CODE.
STOP RUN.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLOYEE
END-EXEC.
01 S-CODE PIC S9(3) SIGN LEADING SEPARATE.
01 WS-SAL PIC 9(6).
PROCEDURE DIVISION.
* EXEC SQL
* INSERT INTO TECH202.EMPLOYEES VALUES
* ("E002", "RAJA", "D001", 10000)
* END-EXEC.
ACCEPT EMPNO.
ACCEPT ENAME.
ACCEPT DEPTNO.
ACCEPT WS-SAL.
MOVE WS-SAL TO SALARY.
EXEC SQL
INSERT INTO TECH202.EMPLOYEES VALUES
(:EMPNO, :ENAME, :DEPTNO, :SALARY)
END-EXEC.
MOVE SQLCODE TO S-CODE.
DISPLAY S-CODE.
STOP RUN.
--------------------------------------------------------------------
UPDATE
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLOYEE
END-EXEC.
01 S-CODE PIC S9(3) SIGN LEADING SEPARATE.
01 WS-SAL PIC 9(6).
PROCEDURE DIVISION.
MOVE 70000 TO SALARY.
EXEC SQL
UPDATE TECH202.EMPLOYEES SET SALARY = :SALARY
WHERE EMPNO = "E001"
END-EXEC.
IF SQLCODE = 0
DISPLAY 'UPDATE SUCCESSFUL'
ELSE
MOVE SQLCODE TO S-CODE
DISPLAY S-CODE
END-IF.
STOP RUN.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLOYEE
END-EXEC.
01 S-CODE PIC S9(3) SIGN LEADING SEPARATE.
01 WS-SAL PIC 9(6).
PROCEDURE DIVISION.
MOVE 70000 TO SALARY.
EXEC SQL
UPDATE TECH202.EMPLOYEES SET SALARY = :SALARY
WHERE EMPNO = "E001"
END-EXEC.
IF SQLCODE = 0
DISPLAY 'UPDATE SUCCESSFUL'
ELSE
MOVE SQLCODE TO S-CODE
DISPLAY S-CODE
END-IF.
STOP RUN.
--------------------------------------------------------------------
DELETE
IDENTIFICATION DIVISION.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLOYEE
END-EXEC.
01 S-CODE PIC S9(3) SIGN LEADING SEPARATE.
PROCEDURE DIVISION.
EXEC SQL
DELETE FROM TECH202.EMPLOYEES WHERE EMPNO = "E002"
END-EXEC.
IF SQLCODE = 0
DISPLAY 'DELETE SUCESSFUL'
ELSE
MOVE SQLCODE TO S-CODE
DISPLAY S-CODE
END-IF
STOP RUN.
PROGRAM-ID. SAMPLE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL
INCLUDE SQLCA
END-EXEC.
EXEC SQL
INCLUDE EMPLOYEE
END-EXEC.
01 S-CODE PIC S9(3) SIGN LEADING SEPARATE.
PROCEDURE DIVISION.
EXEC SQL
DELETE FROM TECH202.EMPLOYEES WHERE EMPNO = "E002"
END-EXEC.
IF SQLCODE = 0
DISPLAY 'DELETE SUCESSFUL'
ELSE
MOVE SQLCODE TO S-CODE
DISPLAY S-CODE
END-IF
STOP RUN.
No comments:
Post a Comment