Re: 4gl / c interface
Posted in 1995
Richard Spitz wrote: > > Sanjay Kumar (SOHO!dpsanjay@whitestone.raileurope.com) wrote: > > : Is there a way for me to return multiple rows of data from an ESQL/C > : function to a 4gl program. > > Sanjay, > > my solution to this problem is somewhat kludgy, but it has worked for me > on numerous occasions: > > I create a temp table within the 4GL program for the rows to be returned. > In the ESQL/C function, I INSERT the rows into that table, and if necessary, > I RETURN the number of rows inserted to the 4GL program (or a negative > error code). The 4GL program then SELECTs the rows from that temp table > and drops it after use. > > The advantage of this approach is that the number of rows returned is > practically unlimited, you are not necessarily bound by a static array > of records. > > Hope this helps, > Richard > -- > +----------------------------+-------------------------------------------+ > | Dr. Richard Spitz | INTERNET: spitz@ana.med.uni-muenchen.de | > | EDV-Gruppe Anaesthesie | Tel : +49-89-7095-3421 | > | Klinikum Grosshadern | FAX : +49-89-7095-8886 | > | 81366 Munich, Germany | | > +----------------------------+-------------------------------------------+Dr, and Sanjay, I also ran into another method which is in line with your suggestion, but eliminates the need for a temp table. It's a bit more tedious to set up, but works pretty good. Instead of using a temp table, you retrieve the rows into a linked-list. The advantage here is the malloc for dynamic memory. Once you've loaded up the linked list, which is the equivalent of a temp table, you can then set up a fetch routine to get the next n records, in "pages" to be displayed in an INPUT/DISPLAY ARRAY. Your menu can have "FORWARD" and "PREVIOUS", synchronized with the linked list. Don't know linked lists? A really good book--one of the few out there with a very nice discussion is "Practical C Programming" from O'reilly and Associates. It isn't the most intuitive concept in C, but may offer you a way besides using temp tables. Your temp table is in memory instead of using up the disk... Hope this helps! -- \\\\|// (6 6) ==============================---o00--(_)--00o---============================ Tim Schaefer (800)587-9502 http://www.gate.net/~tschaefe The Computer Business Company, Inc. tschaefe@gate.net =============================================================================