Re: 4gl Input array question?
Posted in 1997
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Triggers, Constraints & Referential Integrity
Matt Brickley <mbrickley@InfoAve.Net> wrotg: >4GL 4.12, SE 5.01, SCO Unix 3.2v4.2 > >I have a table with 8 columns. I want to let the user update, delete, >or insert to a screen array with only 6 of the columns displaying. >How can I do this when the number of variables in the screen array must >match the program array? > >For simplicity sake, I want to let 4gl handle the array and when the user >is done modifying the array, I want to delete all of the rows in the >table and insert all of the changed rows from the screen/program array > > >TIA Matt--- I've run into this situation many, many times. My functional solution was to rework a piece of example code provided in Informix's 4GL Examples book ( can't recall where it was, but a 'valid_array_null' function is in the code and is in the function index ), the one that synchronizes two different arrays. Like you, I define one array to contain only the displayable fields. Then, I globally declare another array to hold keys and any other significant non-displayable fields. It also contains a flag field to track any modifications the user makes during the input array statement. The reworked sample code is integrated into the input array code and keeps the two arrays in sync as records are added, updated or deleted from the displayed array. When the user exits the input array statement, another piece of code scans the flag field within the key array, triggering the appropriate SQL action against the database. An enhancement I added was keep track of the 'touch' status of the array by executing a field_touched( s_row.* ) after every row, insert, or delete. If nothing's been touched, I exit immediatedly back to the calling routine without triggering any SQL actions. Reloads are triggered only if made some changes were made to the array, then cancelled, or if the SQL actions failed. If you would like, I can send along some samples. In the meantime, see if you can find the example code in the Informix 4GL examples code. It should give you a start on what I'm yapping about. ATT Starserver E, System V/386 Release 4.2, Informix-R4GL v.4.1, Online 4.01. --- dave koehler Anti-spam address!!! Change the "fantasia.com" to "ameritech.net".