philippoommen1
Member
Hi,
Please tell me how can I populate the temp-table from a Dataset.
I have set of datasets each has more than one Temp table schema and data (Each time temp table structure varies ). What I would like to do is after a procedure run , I should be able to write code
For each temp-XXXXX :
Disp temp-XXXXX.YYYY.
end.
For this I need to create the temp-table dynamically. Is it possible?
FYI - I could prepare the query from the following code. But my requirement is to prepare the temp-table. Is it possible? Please help me.
REPEAT icount = 1 TO hDataSet:NUM-TOP-BUFFERS:
hBuffer = hDataSet:GET-TOP-BUFFER(iCount).
RUN p_querybuild(INPUT hBuffer).
END.
PROCEDURE p_querybuild :
DEFINE INPUT PARAMETER iphBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.
DEFINE VARIABLE iField AS INTEGER NO-UNDO.
CREATE QUERY hQuery.
hQuery:SET-BUFFERS((iphBuffer)).
hQuery:QUERY-PREPARE("FOR EACH " + iphBuffer:TABLE + " NO-LOCK").
hQuery:QUERY-OPEN().
hQuery:GET-FIRST().
OUTPUT TO c:\X.txt APPEND.
DO WHILE hQuery:QUERY-OFF-END = FALSE:
DO iField = 1 TO iphBuffer:NUM-FIELDS:
hField = hBuffer:BUFFER-FIELD(iField).
EXPORT hField:BUFFER-VALUE.
END.
hQuery:GET-NEXT().
END.
OUTPUT CLOSE.
END PROCEDURE.
Please tell me how can I populate the temp-table from a Dataset.
I have set of datasets each has more than one Temp table schema and data (Each time temp table structure varies ). What I would like to do is after a procedure run , I should be able to write code
For each temp-XXXXX :
Disp temp-XXXXX.YYYY.
end.
For this I need to create the temp-table dynamically. Is it possible?
FYI - I could prepare the query from the following code. But my requirement is to prepare the temp-table. Is it possible? Please help me.
REPEAT icount = 1 TO hDataSet:NUM-TOP-BUFFERS:
hBuffer = hDataSet:GET-TOP-BUFFER(iCount).
RUN p_querybuild(INPUT hBuffer).
END.
PROCEDURE p_querybuild :
DEFINE INPUT PARAMETER iphBuffer AS HANDLE NO-UNDO.
DEFINE VARIABLE hQuery AS HANDLE NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.
DEFINE VARIABLE iField AS INTEGER NO-UNDO.
CREATE QUERY hQuery.
hQuery:SET-BUFFERS((iphBuffer)).
hQuery:QUERY-PREPARE("FOR EACH " + iphBuffer:TABLE + " NO-LOCK").
hQuery:QUERY-OPEN().
hQuery:GET-FIRST().
OUTPUT TO c:\X.txt APPEND.
DO WHILE hQuery:QUERY-OFF-END = FALSE:
DO iField = 1 TO iphBuffer:NUM-FIELDS:
hField = hBuffer:BUFFER-FIELD(iField).
EXPORT hField:BUFFER-VALUE.
END.
hQuery:GET-NEXT().
END.
OUTPUT CLOSE.
END PROCEDURE.