Dynamic Temp-table

emnu

Member
Hi All,

I just asked myself the question if it woudl be possible to use a FIND statement to find a certain record within a dynamically created temp-table (in place the result is just 1 record of course) or do we always have to create a query with a FOR EACH, even
if the result is only one record ?




/* handle to temp table */
CREATE TEMP-TABLE ttHandle.

/* table which we use*/
ttHandle:CREATE-LIKE("krediet").


/* needed fiels, all in this case*/
ttHandle:ADD-FIELDS-FROM("krediet").


ttHandle:TEMP-TABLE-PREPARE("ttKrediet").

/* buffer handle to temp-table */
bfHandle = ttHandle:DEFAULT-BUFFER-HANDLE.

/* Create Query for tt*/

CREATE QUERY qHandle.

/* handle to temp-table buffer */
qHandle:SET-BUFFERS(bfHandle).

/* Query to find 1 record

ASSIGN cQuery = "FOR EACH ttKrediet WHERE ttKrediet.ln-nr = " + STRING(lening.ln-nr) +
" AND ttKrediet.kl-nr = " + STRING(lening2.kl-nr) +
" AND ttKrediet.kr-nr = " + STRING(cRow).

/* prepary query */
qHandle:QUERY-PREPARE(cQuery).

/* run query */
qHandle:QUERY-OPEN().

qHandle:GET-NEXT().
IF NOT qHandle:QUERY-OFF-END THEN
DO:
ASSIGN
fHandle1 = bfHandle:buffer-field("KT-CODE")
fHandle2 = bfHandle:buffer-field("KR-NAAM").
MESSAGE fHandle1:BUFFER-VALUE() SKIP fHandle2:BUFFER-
VALUE().
END.

/* release objecten & handles */
qHandle:QUERY-CLOSE().
DELETE OBJECT qHandle.

Thanx for any Response
Emmanuel Nuyttens
C&C NV - Oudenaarde - Belgium
 

cybvek

New Member
Hi!

I think there is no way to use "find" in a dynamic query even you want just get the first, only "for each" can be used at a d/s query. I have never seen that kind of examle, where somebody use another "tool" as d. query to find something in a d. temp-table.

Regards,

Viktor

Originally posted by emnu
Hi All,

I just asked myself the question if it woudl be possible to use a FIND statement to find a certain record within a dynamically created temp-table (in place the result is just 1 record of course) or do we always have to create a query with a FOR EACH, even
if the result is only one record ?




/* handle to temp table */
CREATE TEMP-TABLE ttHandle.

/* table which we use*/
ttHandle:CREATE-LIKE("krediet").


/* needed fiels, all in this case*/
ttHandle:ADD-FIELDS-FROM("krediet").


ttHandle:TEMP-TABLE-PREPARE("ttKrediet").

/* buffer handle to temp-table */
bfHandle = ttHandle:DEFAULT-BUFFER-HANDLE.

/* Create Query for tt*/

CREATE QUERY qHandle.

/* handle to temp-table buffer */
qHandle:SET-BUFFERS(bfHandle).

/* Query to find 1 record

ASSIGN cQuery = "FOR EACH ttKrediet WHERE ttKrediet.ln-nr = " + STRING(lening.ln-nr) +
" AND ttKrediet.kl-nr = " + STRING(lening2.kl-nr) +
" AND ttKrediet.kr-nr = " + STRING(cRow).

/* prepary query */
qHandle:QUERY-PREPARE(cQuery).

/* run query */
qHandle:QUERY-OPEN().

qHandle:GET-NEXT().
IF NOT qHandle:QUERY-OFF-END THEN
DO:
ASSIGN
fHandle1 = bfHandle:buffer-field("KT-CODE")
fHandle2 = bfHandle:buffer-field("KR-NAAM").
MESSAGE fHandle1:BUFFER-VALUE() SKIP fHandle2:BUFFER-
VALUE().
END.

/* release objecten & handles */
qHandle:QUERY-CLOSE().
DELETE OBJECT qHandle.

Thanx for any Response
Emmanuel Nuyttens
C&C NV - Oudenaarde - Belgium
 

jongpau

Member
Hi Emmanuel,

Apparently 9.1D will have a method that allows you to do FIND's on dynamic buffers (and hopefully temp-tables). This find method would allow you to find records in a buffer without having to create, open and closing queries (which *should* mean a performance increase and definately means a lot less coding:)).

It's announced in the "What's new in Progress 9.1D" pdf as: "New methods and a new attribute will allow singleton finding on a dynamic buffer object. They complement the already existing Buf-hdl:FIND-BY-ROWID."
 
Top