[USflag] The American Programmer [USflag]


Home
Books on Mainframe Programming
Mainframe Manuals and Tutorials
System Abend codes, Sqlcodes, VSAM/QSAM codes
Everything about the IBM AS/400 Midrange Computer
Everything about CICS
Everything about COBOL
Everything about DB2 and SQL
  DB2/SQL Singleton Select embedded in a COBOL program
  DB2/SQL Add Change Delete program
  DB2/SQL program to read table with cursor
  DB2/SQL load table program
  DB2/SQL program to read a table randomly
  DB2/SQL bare bones skeleton program
  DB2/SQL program to insert a row into a table
  DB2/SQL program to update a row
  DB2/SQL program for handling variable length column
  DB2/SQL program for handling column with null indicator
  Embedded SQL. Short tutorial.
  Examples of DCLGEN. Short tutorial.
  Examples of SQL Joins. Short tutorial.
  Examples of DB2 View. Short tutorial.
  Just Enough SQL/QMF/SPUFI To Be Dangerous
  Sample tables STAFF, ORG, EMP and DEPT
  QMF Procedures Written in REXX
  Using REXX Subroutines with the QMF Calc panel
  Using QMF to Execute Your SQL
  QMF Cheat Sheet. Edit codes. QMF Commands, Text Variables, Usage Codes
  Executing SQL in a batch job
  Using Spufi to Execute Your SQL
  Books on DB2 and SQL
  DB2 and SQL, Structured Query Language manuals
  SQLCODES and Their Causes
Everything about IMS
Everything about Java and JavaScript
Everything about JCL and JES
Everything about REXX
Everything about zOS, VSAM, Tivoli, Assembler
Everything about TSO, ISPF, Spufi
Site Map and Site Search

           Home   > DB2 and SQL   > Update a row, in Embedded SQL

Description of the example tables STAFF, ORG, EMP and DEPT

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. 'UPDTROW'.
000400* UPDATE A ROW ON STAFF
000401*
000402* AFTER RUNNING YOUR PROGRAM, YOU MAY CHANGE THE DATA BACK
000403* TO WHAT IT WAS WITH THIS CODE:
000410*       UPDATE STAFF
000420*          SET  JOB    = 'SALES',
000430*               SALARY = 18001.75
000440*          WHERE ID = 90 ;
000470*
000500 ENVIRONMENT DIVISION.
000600 INPUT-OUTPUT SECTION.
000700 FILE-CONTROL.
000800 DATA DIVISION.
000900 FILE SECTION.
001000 WORKING-STORAGE SECTION.
001100     EXEC SQL
001200            INCLUDE SQLCA
001300     END-EXEC.
001400
001500     EXEC SQL
001600            INCLUDE STAFF
001700     END-EXEC.
001800
001900 01  DISPLAY-SQLCODE PIC Z(8)9-.
001910
002000 01  NULL-NAME       PIC S9(4) COMP VALUE ZERO.
002100 01  NULL-DEPT       PIC S9(4) COMP VALUE ZERO.
002200 01  NULL-JOB        PIC S9(4) COMP VALUE ZERO.
002300 01  NULL-YEARS      PIC S9(4) COMP VALUE ZERO.
002400 01  NULL-SALARY     PIC S9(4) COMP VALUE ZERO.
002500 01  NULL-COMM       PIC S9(4) COMP VALUE ZERO.
002600
002700
002800 PROCEDURE DIVISION.
002900
003000     DISPLAY 'STARTING PROGRAM work4'.
003100
003200     MOVE 90 TO ID-X
003300     MOVE 'DRONE' TO JOB
003400     MOVE 72000 TO SALARY
003500     MOVE 0 TO NULL-JOB, NULL-SALARY
003520
003600     EXEC SQL
003700         UPDATE STAFF
003800            SET  JOB    = :JOB:NULL-JOB,
003810                 SALARY = :SALARY:NULL-SALARY
003900            WHERE ID = :ID-X
004000     END-EXEC
004100
004200     EVALUATE SQLCODE
004300       WHEN 0
004400         DISPLAY 'SUCCESSFULLY UPDATED STAFF '
004500       WHEN +100
004600         DISPLAY 'NOT FOUND '
004700       WHEN OTHER
004800         GO TO ERROR-EXIT
004900      END-EVALUATE
005000
005100     DISPLAY 'FINISHED NOW'.
005200     GOBACK.
005300
005400 ERROR-EXIT.
005800     MOVE SQLCODE TO DISPLAY-SQLCODE.
005900     DISPLAY 'SQLCODE FOLLOWS' DISPLAY-SQLCODE
006000     GOBACK.
005400**HTTP://theamericanprogrammer.com/db2-sql/index.html



Top of Page




















































































List of books on DB2 and other mainframe topics

[Books Computer]

Home Books for Computer Professionals Privacy Terms |
Site Map and Site Search Programming Manuals and Tutorials The REXX Files Top of Page |