如何使用 dbisqlc.exe 命令收集列标题和数据

发布于 2024-10-19 21:12:19 字数 413 浏览 5 评论 0原文

我正在尝试在 Windows 系统上使用 dbisqlc.exe 命令行查询 Sybase ASA 数据库,并希望收集列标题以及关联的表数据。

示例:

dbisqlc.exe -nogui -c "ENG=myDB;DBN=dbName;UID=dba;PWD=mypwd;CommLinks=tcpip{PORT=12345}" select * from myTable; OUTPUT TO C:\OutputFile.txt

如果此命令写入 stdout,我会更喜欢,但是除了使用在我所在的环境中不可用的 dbisql.exe 之外,这似乎不是一个选项 当我以

这种格式运行它时,标题和数据会以不可解析的格式生成。

任何帮助将不胜感激。

I am trying to query a Sybase ASA database using the dbisqlc.exe command-line on a Windows system and would like to collect the column headers along with the associated table data.

Example:

dbisqlc.exe -nogui -c "ENG=myDB;DBN=dbName;UID=dba;PWD=mypwd;CommLinks=tcpip{PORT=12345}" select * from myTable; OUTPUT TO C:\OutputFile.txt

I would prefer it if this command wrote to stdout however that does not appear to be an option aside from using dbisql.exe which is not available in the environment I am in.

When I run it in this format the header and data is generated however in an unparsable format.

Any assistance would be greatly appreciated.

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

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

发布评论

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

评论(2

中性美 2024-10-26 21:12:19

尝试将“FORMAT SQL”子句添加到 OUTPUT 语句中。它将为您提供包含列名和数据的选择语句。

Try adding the 'FORMAT SQL' clause to the OUTPUT statement. It will give you the select statement containing the column names as well as the data.

撑一把青伞 2024-10-26 21:12:19

在查看以下 dbisqlc.exe 命令的输出时,我似乎可以使用 perl 解析输出。

命令:
dbisqlc.exe -nogui -c "ENG=myDB;DBN=dbName;UID=dba;PWD=mypwd;CommLinks=tcpip{PORT=12345}" 从 myTable 中选择 *;输出到 C:\OutputFile.txt

使用 vi 或 TextPad 等文本编辑器,输出似乎在奇怪的地方中断,但该命令的输出实际上以特定的列宽返回。

输出的第二行包含一组 = 符号,它们包含在每列的宽度中。我所做的是基于 = 构建一个“template”字符串,该字符串可以传递给 perls unpack 函数。然后,我使用此模板构建列名称数组,并使用 unpack 解析结果集。

这可能不是最有效的方法,但我认为它应该给我我正在寻找的结果。

In reviewing the output from the following dbisqlc.exe command, it appears as though I can parse the output using perl.

Command:
dbisqlc.exe -nogui -c "ENG=myDB;DBN=dbName;UID=dba;PWD=mypwd;CommLinks=tcpip{PORT=12345}" select * from myTable; OUTPUT TO C:\OutputFile.txt

The output appears to break in odd places using text editors such as vi or TextPad however the output from this command is actually returned with specific column widths.

The second line of the output includes a set of ='s signs which are contained for the width of each column. What I did was build a "template" string based on the ='s which can be passed to perls unpack function. I then use this template to build an array of column names and parse the result set using unpack.

This may not be the most efficient method however I think it should give me the results I am looking for.

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