|
Dave, I think you are using the term "data structure" differently than the poster meant. It is a specific term of art in RPG, similar to a struct in C. Your SAL-REC in COBOL is the closest thing to it, but the example there is a SELECT INTO, not an UPDATE. The idea is to use what the SQL books call a "host structure" instead of a comma-delimited list of "host variables". It is a shortcut which the UPDATE did not used to have. At V5R1 it became possible to use the syntax Birgitta mentioned, "set row = :dsname" which assumes that the DS (RPG data structure) has elements for all the columns in the row. Murky? Sorry if it is. Later Vern -------------- Original message -------------- From: "Dave Odom" <Dave.Odom@xxxxxxxxxxxx> > Luqman, > > Let me give you a few examples in different languages and see if this > helps. If not, please explain further. The following are examples of > the UPDATE statement using data structures in programs in C, COBOL and > REXX: > > void main () > { > EXEC SQL BEGIN DECLARE SECTION; > decimal(5,2) AMOUNT; > char FROM_EMPNO[7]; > char TO_EMPNO[7]; > EXEC SQL END DECLARE SECTION; > EXEC SQL INCLUDE SQLCA; > EXEC SQL WHENEVER SQLERROR GOTO SQLERR; > ... > EXEC SQL UPDATE EMPLOYEE > SET COMM = COMM - :AMOUNT > WHERE EMPNO = :FROM_EMPNO; > EXEC SQL UPDATE EMPLOYEE > SET COMM = COMM + :AMOUNT > WHERE EMPNO = :TO_EMPNO; > FINISHED: > EXEC SQL COMMIT WORK; > return; > > For example, in COBOL: > 01 SAL-REC. > 10 MIN-SAL PIC S9(6)V99 USAGE COMP-3. > 10 AVG-SAL PIC S9(6)V99 USAGE COMP-3. > 10 MAX-SAL PIC S9(6)V99 USAGE COMP-3. > 01 SALTABLE. > 02 SALIND PIC S9999 USAGE COMP-4 OCCURS 3 TIMES. > 01 EDUC-LEVEL PIC S9999 COMP-4. > ... > MOVE 20 TO EDUC-LEVEL. > ... > EXEC SQL > SELECT MIN(SALARY), AVG(SALARY), MAX(SALARY) > INTO :SAL-REC:SALIND > FROM CORPDATA.EMPLOYEE > WHERE EDLEVEL>:EDUC-LEVEL > END-EXEC. > > REXX: > > ADDRESS '*COMMAND', > SIGNAL ON ERROR > UPDATE_STMT = 'UPDATE CORPDATA/EMPLOYEE ', > 'SET SALARY = SALARY * ? ', > 'WHERE COMM >= ? ' > EXECSQL, > 'PREPARE S1 FROM :UPDATE_STMT' > EXECSQL, > 'EXECUTE S1 USING :PERCENTAGE,', > ' :COMMISSION ' > /* Commit changes */ > EXECSQL, > 'COMMIT' > > HTH, > > Dave > -- > This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list > To post a message email: MIDRANGE-L@xxxxxxxxxxxx > To subscribe, unsubscribe, or change list options, > visit: http://lists.midrange.com/mailman/listinfo/midrange-l > or email: MIDRANGE-L-request@xxxxxxxxxxxx > Before posting, please take a moment to review the archives > at http://archive.midrange.com/midrange-l. >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.