如何覆盖字符一批可变数量限制? [英] How to override batch variable number of characters limit?

查看:169
本文介绍了如何覆盖字符一批可变数量限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在的当前项目我工作的问题。
我得从一个文件存储到一个变量,它的文件只包含查询(它是由程序的一部分生成)的查询。比如我用下面的code:

I'm having an issue on the current project I'm working on. I have to get a query stored from a file into a variable, whose file only contains a query (It is generated by part of the program). For instance I use the following code:

set /p query=<path\to\my\folder\fileContainingQuery.soql

它的工作原理当查询并不长,但是当它的长度超过1024个字符,查询被截断,因为我得将其发送到使用屁工具另外一个配置文件,这是相当不方便。

It works when the query isn't that long, but when its length is beyond 1024 characters, the query is truncated and since I gotta send it to another configuration file using the FART tool, that's quite not convenient.

如何重写这个问题?

推荐答案

有在多少数据可以存储在一个环境变量的限制。理论上,最大长度为32767个字符,但一个批处理文件不能设置一个变量,它是比最大命令行长度(8192)长。

There is a limit in how many data can be stored in a environment variable. In theory, the maximum length is 32767 characters, BUT a batch file cannot set a variable that is longer than the maximum command line length (8192).

您可以使用 FOR / F 命令来读取行

You can use a for /f command to read the line

for /f "usebackq delims=" %%f in ("path\to\my\folder\fileContainingQuery.soql") do set "q=%%f"

或者你也可以生成一个辅助的批处理文件来查询的内容分配

Or you can generate a auxiliary batch file to assign the content of the query

<nul set/px=set q=>sql.set.cmd
type "path\to\my\folder\fileContainingQuery.soql">>sql.set.cmd
call sql.set.cmd

,都将获得最大的文本变量只有最后的命令行不是太大(8186字在我的测试)。在其他情况下,没有被检索。

And both will get the maximum possible text into the variable ONLY if the final command line is not too big (8186 characters in my tests). In other case, nothing is retrieved.

但,一旦该值被检索,是有一个命令内使用。在这里,同样的限制情况。 8192是最大行长度和可变的内容的行内IS。

BUT, once the value has been retrieved, is has to be used inside a command. And here the same limitation happens. 8192 is the maximum line length and the content of the variable IS inside the line.

所以,你的用于查询的长度最终极限小于

So, your final limit for the length of the query is less than that.

这篇关于如何覆盖字符一批可变数量限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆