Question Past Temp-table between files

Hi
Here my need, I want to create a file (eg proc.p) with in input parameter a temporary table. So I can call this file in another program. The table that is passed as a parameter can be different depending of the program that call it.
The only thing I got is to pass table in parameter but it must be previously declared in the second file. But as I said I don't know what table will be passed.
What I want to do is a procedure which copies a table into SQL a temporary table passed in parameter. If you know bether solution ...
 
The TABLE-HANDLE passes the HANDLE of the Temp-table but how can I use it... This Handle only alow me to add fields not to query the temp table?
 

Cringer

ProgressTalk.com Moderator
Staff member
You can create a dynamic query on the handle.
Code:
CREATE BUFFER lv-Buffer FOR TABLE ip-TableHandle:DEFAULT-BUFFER-HANDLE.

CREATE QUERY lv-Query.
lv-Query:SET-BUFFERS(lv-Buffer).

lv-QueryString = "FOR EACH " + ip-TableHandle:NAME.

lv-Query:QUERY-PREPARE(lv-QueryString).

lv-Query:QUERY-OPEN.

lv-Query:GET-FIRST.

DO WHILE NOT lv-Query:QUERY-OFF-END:
  **something**
  lv-query:GET-NEXT. 
END.

lv-Query:QUERY-CLOSE. 
DELETE OBJECT lv-Query.
 

Stefan

Well-Known Member
Yuck (I nearly reported your post for this... ;-)):

Code:
lv-Query:QUERY-OPEN.
lv-Query:GET-FIRST.
DO WHILE NOT lv-Query:QUERY-OFF-END:
   **something**
    lv-query:GET-NEXT.
END.
lv-Query:QUERY-CLOSE.

Yum:

Code:
hq:QUERY-OPEN().
DO WHILE hq:GET-NEXT():
   ** something **
END.
hq:QUERY-CLOSE().
 

Cringer

ProgressTalk.com Moderator
Staff member
lol Stefan I had no idea you could do that. You learn something new every day. Thanks.
 

Cringer

ProgressTalk.com Moderator
Staff member
Can you post the definitions at the top of the procedure, as well as the call to it?
 
Why only "MESSAGE" work. I try to stock value on variable and Display it and that don't work. here the code...

Code:
test.p
 
 
DEFINE VAR h-table AS HANDLE.
 
DEF NEW GLOBAL  SHARED TEMP-TABLE  t-test
FIELD c-test AS CHAR.
 
CREATE  t-test .
ASSIGN t-test.c-test ="eee".
 
CREATE  t-test .
ASSIGN t-test.c-test ="fff".
 
h-table = TEMP-TABLE t-test:HANDLE.
 
RUN mods/custom/test2.p(INPUT TABLE-HANDLE h-table).


Code:
test2.p
 
DEFINE INPUT PARAMETER TABLE-HANDLE t-handle.
DEFINE VAR c-display AS CHAR.
DEFINE VAR b-handle AS HANDLE.
DEFINE VAR q-handle AS HANDLE.
 
CREATE BUFFER b-handle FOR TABLE t-handle:DEFAULT-BUFFER-HANDLE.
b-handle:BUFFER-CREATE.
 
 
CREATE QUERY q-handle.
q-handle:SET-BUFFERS(b-handle).
q-handle:QUERY-PREPARE("FOR EACH t-test").
q-handle:QUERY-OPEN.
 
DO WHILE q-handle:Get-next():
 
    DISPLAY b-handle:BUFFER-FIELD(1):BUFFER-VALUE.
    MESSAGE b-handle:BUFFER-FIELD(1):BUFFER-VALUE.
    ASSIGN  c-display = b-handle:BUFFER-FIELD(1):BUFFER-VALUE.
    DISPLAY c-display.
 
 
END.
 

RealHeavyDude

Well-Known Member
Your problem most likely is flushing - which reminds me of the good ole V6 days ...

Seriously: Progress automatically always creates a frame to display. The default is a single frame unless you specify otherwise. In order to get a down frame you must use a "real" loop like REPEAT instead of DO. A single frame only displays one lineand overwrites it on each iteration of your "pseudo" loop.

To illustrate that try the following
Code:
DEFINE VARIABLE counter AS INTEGER    NO-UNDO INITIAL 10.
DO WHILE counter > 0:
    ASSIGN counter = counter - 1.
    DISPLAY counter.
END.
vs
Code:
DEFINE VARIABLE counter AS INTEGER    NO-UNDO INITIAL 10.
REPEAT WHILE counter > 0:
    ASSIGN counter = counter - 1.
    DISPLAY counter.
END.

Isn't default behavior funny?

Heavy Regards, RealHeavyDude.
 
Yes that is... Thank you guys. It's the first time I have to play with handle, I learn a lot with this case. I hope all will work find for the rest of my procedure.

Thanks
 

Cringer

ProgressTalk.com Moderator
Staff member
Just as a note, you can also get the BUFFER-FIELD by name, so if your table has a field on it called CustomerNumber on it, then you can get it by b-handle:BUFFER-FIELD("CustomerNumber"):BUFFER-VALUE. The advantage of this is that you can shorten it to b-handle::CustomerNumber. This came in in v10 IIRC.
 
Top