Consultor Eletrônico



Kbase P143275: How to buffer-copy records from Progress/OpenEdge database table to a foreign database table using D
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   3/23/2009
Status: Unverified

GOAL:

How to buffer-copy records from Progress/OpenEdge database table to a foreign database table using DataServer?

FACT(s) (Environment):

All Supported Operating Systems
Progress 9.1x
OpenEdge 10.x
DataServer

FIX:

Buffer-copy excludes records on the fields/columns that are larger in length than the actual length of the fields/columns in the foreign database.  The following code sample shows how to buffer-copy records as well as capture the error in case the records on the specific field/column is not being copied for the length issue.

DEFINE VARIABLE cSourceBuff AS CHARACTER  NO-UNDO INITIAL "<db logical name>.<table name>".
DEFINE VARIABLE cTargetBuff AS CHARACTER  NO-UNDO INITIAL "<db logical name>.<table name>". DEFINE VARIABLE hSource AS HANDLE     NO-UNDO.
DEFINE VARIABLE hTarget AS HANDLE     NO-UNDO.
DEFINE VARIABLE hQuery  AS HANDLE     NO-UNDO. CREATE WIDGET-POOL. CREATE BUFFER hSource FOR TABLE cSourceBuff.
CREATE BUFFER hTarget FOR TABLE cTargetBuff. CREATE QUERY hQuery. hQuery:SET-BUFFERS(hSource).
hQuery:QUERY-PREPARE("FOR EACH " + hSource:NAME + " NO-LOCK").
hQuery:QUERY-OPEN().
hQuery:GET-FIRST(). DO WHILE NOT hQuery:QUERY-OFF-END
   TRANSACTION:   hTarget:BUFFER-CREATE().
  hTarget:BUFFER-COPY(hSource) NO-ERROR.
  hTarget:BUFFER-RELEASE().
/*   MESSAGE ERROR-STATUS:ERROR ERROR-STATUS:NUM-MESSAGES */
/*       VIEW-AS ALERT-BOX INFO BUTTONS OK.                                        */
  IF ERROR-STATUS:NUM-MESSAGES GT 0 THEN DO:
    MESSAGE ERROR-STATUS:GET-MESSAGE(1)
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
  END.  hQuery:GET-NEXT(). END.