Re: HELP - Using a cursor in 4gl
Posted in 1996
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration
Alberto Pardo Fernandez wrote: > > Hi. > > I need to recover data from a table in a 4gl program. I dont know neither the > table name nor the table structure at compile time. Although I can find it out > at run time, I cant declare a record with DEFINE my_record RECORD LIKE tabname.* > (tabname is a variable that holds the name of my table). > > How can I access to the data recovered by the cursor? Is there any way to access > the field values of the cursor? > > DEFINE tablename CHAR(20) > DEFINE my_field CHAR(20) > . > . > . > LET sql = "select * from ", tablename > > PREPARE query FROM sql > DECLARE my_cursor CURSOR FOR query > > FOREACH my_cursor > # Here I want to access the values of the fields of my_cursor > # How can I access the field whose name is the value of my_field > END FOREACH > > Thanks by advance. Alberto: Try out the following code. I have done what you are trying. I have a generic popup/pick list function. I can send it to you if you would like. Ron Delpiere-Smith Informix DBA --------------------------------------------------------------------------------- DEFINE tablename CHAR(20) DEFINE my_field CHAR(20) DEFINE prog_var CHAR(60) LET sql = "SELECT ", my_field CLIPPED, " FROM ", tablename CLIPPED PREPARE my_cursor DECLARE my_cursor FOREACH my_cursor INTO prog_var .... END FOREACH