如何在缓冲区句柄中使用`export`?

AXM*_*MIM 1 progress-4gl openedge

在删除表之前导出表的数据就像一个超级按钮一样。
范例:

OUTPUT TO VALUE("C:\mytable.d") APPEND.
EXPORT mybd.mytable.
OUTPUT CLOSE. 
DELETE mybd.mytable.
Run Code Online (Sandbox Code Playgroud)

但是,我还没有使它在使用缓冲区句柄时起作用。以下内容将导出一个整数,而不是删除的数据。

DEF INPUT PARAM hlTableToDelete AS HANDLE NO-UNDO.
...
OUTPUT TO VALUE("C:\" + hiTableToDelete:NAME + ".d") APPEND.
EXPORT hlTableToDelete:HANDLE.
OUTPUT CLOSE. 
hlTableToDelete:BUFFER-DELETE().
Run Code Online (Sandbox Code Playgroud)

命令运行export并实际导出缓冲区句柄的数据需要哪种语法?

Tom*_*com 5

EXPORT仅适用于静态缓冲区。缓冲区句柄上没有EXPORT方法。

为了获得等效的功能,您将需要编写一些遍历字段列表的代码。

这些思路可以帮助您入门:

/* export data like EXPORT does
 *
 * makes no attempt to handle LOB data types
 *
 */

function exportData returns logical ( input bh as handle ):

  define variable bf as handle    no-undo.                                      /* handle to the field                          */
  define variable f  as integer   no-undo.                                      /* field number                                 */
  define variable i  as integer   no-undo.                                      /* array index                                  */

  do f = 1 to bh:num-fields:                                                    /* for each field...                            */

    bf = bh:buffer-field( f ).                                                  /* get a pointer to the field                   */

    if f > 1 then put stream expFile unformatted field_sep.                     /* output field separator                       */

    if bf:extent = 0 then                                                       /* is it an array?                              */
      put stream expFile unformatted
        ( if bf:data-type = "character" then                                    /* character data needs to be quoted to */
          quoter( string( bf:buffer-value ))                                    /* handle (potential) embedded delimiters       */
         else                                                                   /* and quotes within quotes!                    */
          string( bf:buffer-value )                                             /* other data types should not be quoted        */
        )
      .
     else                                                                       /* array fields need special handling           */
      do i = 1 to bf:extent:                                                    /* each extent is exported individually         */
        if i > 1 then put stream expFile unformatted field_sep.                 /* and a field separator                        */
        put stream expFile unformatted
          ( if bf:data-type = "character" then                                  /* see above...                                 */
            quoter( string( bf:buffer-value( i )))
           else  
            string( bf:buffer-value( i ))
          )
          field_sep
        .
      end.

  end.

  put stream expFile skip.                                                      /* don't forget the newline! ;-)                */

  return true.

end.
Run Code Online (Sandbox Code Playgroud)