In the first example you see the classical way for filling a temp table.
DEFINE VAR bCustomer AS HANDLE NO-UNDO. DEFINE VAR h-ttCustomer AS HANDLE NO-UNDO. DEFINE VAR httCustomer AS HANDLE NO-UNDO. DEFINE VAR hquery AS HANDLE NO-UNDO. CREATE BUFFER bCustomer FOR TABLE "Customer". CREATE TEMP-TABLE h-ttCustomer. h-ttCustomer:CREATE-LIKE(bCustomer). h-ttCustomer:TEMP-TABLE-PREPARE("tt-Customer"). httCustomer = h-ttCustomer:DEFAULT-BUFFER-HANDLE. CREATE QUERY hquery. hquery:SET-BUFFERS(bCustomer). hquery:QUERY-PREPARE("FOR EACH Customer NO-LOCK"). hquery:FORWARD-ONLY. hquery:QUERY-OPEN. hquery:GET-FIRST(NO-LOCK). DO WHILE NOT hquery:QUERY-OFF-END. httCustomer:BUFFER-CREATE. httCustomer:BUFFER-COPY(bCustomer). hquery:GET-NEXT(NO-LOCK). END. hquery:QUERY-CLOSE. DELETE OBJECT hquery.
Now the same fill the same Temp-Table with the use of a ProDataSet.
DEFINE VAR bCustomer AS HANDLE NO-UNDO. DEFINE VAR h-ttCustomer AS HANDLE NO-UNDO. DEFINE VAR httCustomer AS HANDLE NO-UNDO. DEFINE VAR hDsSource AS HANDLE NO-UNDO. DEFINE VAR hDs AS HANDLE NO-UNDO. CREATE BUFFER bCustomer FOR TABLE "Customer". CREATE TEMP-TABLE h-ttCustomer. h-ttCustomer:CREATE-LIKE(bCustomer). h-ttCustomer:TEMP-TABLE-PREPARE("tt-Customer"). httCustomer = h-ttCustomer:DEFAULT-BUFFER-HANDLE. /* we need a ProDataSet to fill*/ CREATE DATASET hDs. hDs:ADD-BUFFER(httCustomer). CREATE DATA-SOURCE hDsSource. hDsSource:ADD-SOURCE-BUFFER(bCustomer,?). httCustomer:ATTACH-DATA-SOURCE(hDsSource). hDsSource:FILL-WHERE-STRING = "WHERE". /*...*/ hDs:FILL(). httCustomer:DETACH-DATA-SOURCE(). DELETE OBJECT hDsSource.
No comments:
Post a Comment