从 access+VB 6 到 COBOL

发布于 2024-10-18 13:24:17 字数 58 浏览 1 评论 0原文

有人知道有什么方法可以将数据从 access db 导出到 cobol 代码吗?

谢谢

does someone know any way to export data from access db to cobol code?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

客…行舟 2024-10-25 13:24:17

固定格式绝对是最佳选择,任何 Cobol 都可以读取固定格式文件。

在任何 SQL 方言(oracle、DB2、H2 等)中创建固定格式文件的简单方法是使用 SQL 字符串函数创建单个字段并将此查询导出/写入到文件

MS Access 示例查询:

   SELECT Left(Str([TblId])+Space(8),8)
      + Left(Str([tblkey])+Space(20),20)
      + Left([Details]+Space(30),30)
      + "<" AS ExportString
FROM Tbl_TI_IntTbls;

对于 Cobol it最好是右对齐零填充对齐小数点数字字段。

另外,如果这是你一次
可以在访问中运行查询并将输出复制/粘贴到文本编辑器。

Ms Access 还允许您定义固定格式并使用它们来输入(导出?),但自从我使用它们以来已经很长时间了(我使用它们来导入固定宽度数据)。我将把这个问题的讨论留给访问专家。

您还可以查看 RecordEditor (http://record-editor.sourceforge.net/Record11.htm) / JRecord (http://jrecord.sourceforge.net/) 因为

  1. 两者都可以让您查看/编辑文件
    使用 Cobol Copybooks - 有用
    检查导出匹配的 Cobol 定义
  2. 两者都有 Copybook 分析选项
    (文件菜单)将计算
    Cobol 中字段的开始/长度
    字帖
  3. 双方都有复印件
    复制 Csv 文件的函数
    使用 Cobol 与 Cobol 文件之间的传输
    Copybook

注意:这是我的软件的无耻插件,

我会避免使用分隔文件(如果分隔符出现在字段中),但如果必须,请使用模糊字符,例如 ` 或 ~ 或 ^

Fixed Format is definitely the way to go, any Cobol can read a fixed Format File.

A simple way to create a Fixed Format File in any SQL dialect (oracle, DB2, H2 etc) is to use the SQL String functions to create a single Field and export/write this query to a file

MS Access Example Query:

   SELECT Left(Str([TblId])+Space(8),8)
      + Left(Str([tblkey])+Space(20),20)
      + Left([Details]+Space(30),30)
      + "<" AS ExportString
FROM Tbl_TI_IntTbls;

For Cobol it would be best right justify Zero fill and align the decimal points of numeric fields.

Also if this a once off you
can run the query in access an copy / paste the output to a Text Editor.

Ms Access also allows you to define Fixed Formats and use these to input ( export ?) but it is a long time since I used them (I was using them to import fixed width data). I will leave discussion of this to an Access Expert.

You could also look at the RecordEditor (http://record-editor.sourceforge.net/Record11.htm) / JRecord (http://jrecord.sourceforge.net/) because

  1. Both let you View / edit a file
    using a Cobol Copybooks - useful for
    checking the export match's the Cobol Definition
  2. Both have Copybook analysis Option
    (File Menu) that will calculate the
    start / length of fields in a Cobol
    Copybook
  3. Both have copy
    function that will copy a Csv File
    to / from a Cobol File using a Cobol
    Copybook

Note: This is shameless plug for my software

I would avoid a delimited file (in case the delimiter occurs in a field) but if you must, use an obskure character eg ` or ~ or ^

橘亓 2024-10-25 13:24:17

最简单的方法是从 access 导出为固定格式。这是 Cobol 文件数据描述的本机格式。

但是,如果 access 不支持此功能,您可以导出到 CSV(逗号分隔值)文件或 TSV(制表符分隔值)文件。 ANSI 形式的 Cobol 不支持这一点,但使用简单的 Unstring 很容易解析。例如:

Perform Read-A-Record
Perform until End-Of-File

   Unstring Input-Record
     delimited by ","
     into Column-1-Field
          Column-2-Field
          ...
          Column-n-Field

   Perform Read-A-Record
End-Perform

The easiest way would be to export to a fixed with format from access. That is the native format for Cobol file data descriptions.

However, if access does not support this, you can export to a CSV (Comma Seperated Values) file or a TSV (Tab Seperated Values). Cobol, in its ANSI form, does not support this, but it is very easy to parse with a simple Unstring. For example:

Perform Read-A-Record
Perform until End-Of-File

   Unstring Input-Record
     delimited by ","
     into Column-1-Field
          Column-2-Field
          ...
          Column-n-Field

   Perform Read-A-Record
End-Perform
新雨望断虹 2024-10-25 13:24:17

Access 可以通过其导出向导导出为固定字段格式,或者一个简单的 VB6 程序或脚本可以使用 Jet OLEDB Provider 和 Jet 的 Text IISAM 以及定义输出格式的 Schema.ini 文件执行相同的操作。

存在格式限制(没有带符号的打包十进制格式或其他 Cobol 奇异格式),但一般来说,这应该足以创建大多数 Cobol 变体支持的文件。如果确实必须将数字字段左零填充,则可以使用 Jet SQL 表达式服务来实现,该服务允许内联使用 VBA 函数的子集,在 Schema.ini 文件中将结果字段定义为文本。

如果您真正需要的是导出到某种 ISAM 文件,那么最好的选择是编写一个中间 Cobol 程序来导入保存的字段间文本数据。一些 Cobol 产品甚至可能包含进行此类导入的实用程序。

Access can export to fixed-field formats via its Export Wizard or a simple VB6 program or a script can do the same thing using the Jet OLEDB Provider and Jet's Text IISAM, with a Schema.ini file that defines the output format.

There are formatting limitations (no signed packed decimal formats or other Cobol exotica) but in general this should suffice for creating files most Cobol variations support. If you truly must have numeric fields left-zero filled you can do that by using the Jet SQL Expression Service which allows inline use of a subset of VBA functions, defining the result field as Text in the Schema.ini file.

If what you really require is export to some sort of ISAM files your best bet is to write an intermediate Cobol program to import the saved field-field text data. Some Cobol products may even include utilities to do this kind of importing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文