icQueryName | input | character | |
icPrepare | input | character | For each statement for reading the data, excluding the no-lock option (this is implied automatically), excluding break by (not allowed, only normal by is allowed). |
icTables | input | character | Comma seperated list of all database tables in the for each statement. |
ihDestinationBuffer | input | handle | Handle to the temp-table that will receive the data. |
icLastRowid | input | character | Comma seperated list of database record rowids of last record in previous ReadQuery call, contains one rowid for each table in input parameter icTables. Is empty for first call. |
iiLastRownum | input | integer | |
iiMaxNumber | input | integer | Maximum number of records (in the temp-table) to retrieve. Zero if the amount is unlimited. A negative value if exactly one record must be loaded (the record with rowid found in icLastRowid). Remark: if value is +1, also one record will be returned, but this will be the record following record found with icLastRowid. |
icFieldConvert | input | character | Contains the information to know in which temp-table field the database field must be loaded (as opposed to class temp-tables, the field name will be different). Format: '<buffer>.<db-field-1>,<tt-field-1>|<buffer>.<db-field-2>,<tt-field-2>|...' |
icCustomFields | input | character | |
ilDistinct | input | logical | Load only distinct values ? |
ilForwardRead | input | logical | Indicates query should read forward. |
olEof | output | logical | When iiMaxNumber > 0, this parameter will be true when the last record of the query is included in the result set, or when no record was found at all. When iiMaxNumber <= 0, this parameter will be only true when no record was found at all. |
oiReturnStatus | output | integer |
assign oiReturnStatus = -98. /* Convert field list to old format */ do viFcCount1 = 1 to num-entries(icFieldConvert) by 2: assign vcFieldConvert = vcFieldConvert + "|":U + entry(viFcCount1 + 1, icFieldConvert) + ",":U + entry(2,entry(viFcCount1, icFieldConvert),".":U). end. icFieldConvert = substring(vcFieldConvert,2,-1,"CHARACTER":U). if iiMaxNumber = ? then iiMaxNumber = 0. if icLastRowid = ? then icLastRowid = "". &if defined(DEBUGSQL) > 0 &then run SqlDebugWrite in {&TARGETPROCEDURE} ("* ":U + program-name(1), 1). &endif run SqlQryOpen4GL in {&TARGETPROCEDURE} ( icTables, icPrepare, iiMaxNumber, icLastRowid, icFieldConvert, icCustomFields, integer(ilDistinct), output viQryid, output oiReturnStatus). if oiReturnStatus < 0 then do: <M-2 run SqlErrorMessage (input ? (ihClass), output viFcReturnSuper (oiReturnStatus)) in other> return. end. run SqlQryExecute in {&TARGETPROCEDURE} (viQryid, output viCols, output oiReturnStatus). run SqlQryMoveNext in {&TARGETPROCEDURE} (viQryid, output viRows, output oiReturnStatus). /* fill temp-table */ assign viFcCount2 = 0. do while viROws = 1: assign viFcCount2 = viFcCount2 + 1. ihDestinationBuffer:buffer-create(). do viFcCount1 = 0 to viCols - 1: assign vcName = <M-3 getColumnName (input viQryid (iiCmd), input viFcCount1 (iiCol)) in other>. assign vhField = ?. assign vhField = ihDestinationBuffer:buffer-field(vcName) no-error. if vhField <> ? then assign vhField:buffer-value = <M-4 getColumnValue (input viQryid (iiCmd), input viFcCount1 (iiCol)) in other>. end. assign vhField = ?. assign vhField = ihDestinationBuffer:buffer-field("ti_Sequence":U) no-error. if vhField <> ? then assign vhField:buffer-value = viFcCount2. run SqlQryMoveNext in {&TARGETPROCEDURE} (viQryid, output viRows, output oiReturnStatus). end. run SqlQryDestroy in {&TARGETPROCEDURE} (viQryid, output oiReturnStatus). assign oiReturnStatus = 0.