AS400上多成员文件的SQL查询
在 AS400 上的 5250 会话中的交互式 SQL 上,
select * from myfile
仅当 myfile 具有多个成员时才返回来自一个成员的行。
如何获取特定成员的行?
重要提示:最后我想通过 JDBC 使用 jt400 来完成此操作,所以我真的想要一个可以在那里工作的解决方案。
谢谢。
On AS400 in interactive SQL in a 5250 session,
select * from myfile
returns rows from one member only when myfile has more than one member.
How can I get rows from a specific member?
Important: in the end I'd like to do this over JDBC with jt400 so really I want a solution that'll work there.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用 create alias 命令创建别名:
这将允许您像使用任何其他文件一样使用别名对该成员运行 sql:
只需记住,别名将在会话结束后保留下来,它们不是临时的。 因此,如果完成后不需要别名,请在 QTEMP 中创建别名,或者在完成后显式删除别名:
HTH
You can create an alias using the create alias command:
This will allow you to run sql against that member using the alias like you would any other file:
Just remember that the alias will stick around after your session, they are not temporary. So if you wont need the alias when you are done, either create the alias in QTEMP or explicitly drop the alias once you are done with it:
HTH
为成员创建 SQL 别名并查询别名,请参阅 此页面作为示例。
Create an SQL alias for the member and query the alias, see this page for an example.
SQL 别名
OS/400 R430
及更高版本支持SQL
别名语句。 为必须访问的每个成员创建一个别名,然后从应用程序引用该别名。 别名是一个持久对象——它只能创建一次。 创建ALIAS
时,CREATE ALIAS
中引用的成员不必存在。 任何SQL
工具,例如OS/400
或i5/OS 交互式 SQL (STRSQL)
或iSeries Navigator 的运行 SQL 脚本
code>,可用于创建别名,例如:http:// /www-01.ibm.com/support/docview.wss?uid=nas1f1eaeecc0af19cc38625669100569213
SQL Alias
OS/400 R430
and later support anSQL
alias statement. Create an alias for each member that must be accessed, then reference the alias from the application. The alias is a persistent object -- it must be created only once. The member referenced in theCREATE ALIAS
does not have to exist when theALIAS
is created. AnySQL
tool, such asOS/400
ori5/OS interactive SQL (STRSQL)
oriSeries Navigator's Run SQL Scripts
, can be used to create the alias, for example:http://www-01.ibm.com/support/docview.wss?uid=nas1f1eaeecc0af19cc38625669100569213
这是一个旧线程,仍然是搜索结果列表中的第一个,我想增强之前的响应:
有时您只需要创建别名作为一次性数据库分析,然后您想要创建别名并将其删除在您提出查询后立即; 您还有一个包含许多表的数据库库,并且不想在每个查询中限定该库,因此您使用 SET SCHEMA; 我喜欢使用 QTEMP 库来创建别名,因为 IBM i AS400 服务器上的 QTEMP 本质上是用于临时对象的:
This is an old thread and still the first on the search results list, I would like to enhance the previous responses:
Sometimes you only need to create the alias as a one time Database analysis, then you want to create the alias and drop it off immediately after your query; you also have a Data Base library with many tables and don't want to qualify the library in every query so you use SET SCHEMA; I love to use the QTEMP library to create alias since QTEMP by nature on IBM i AS400 servers is for temporary objects:
此查询在 IBM i 7.4 上运行,但也适用于某些早期版本。
选择
SYSTEM_TABLE_SCHEMA AS“库”,
SYSTEM_TABLE_NAME AS“文件”,
SYSTEM_TABLE_MEMBER AS“成员”,
SOURCE_TYPE AS“SrcType”,
TO_CHAR(NUMBER_ROWS,'999G999G999G999') AS "记录",
TO_CHAR(DATA_SIZE,'999G999G999G999') AS "大小",
PARTITION_TEXT AS“文本”,
CREATE_TIMESTAMP AS“创建日期”,
LAST_SOURCE_UPDATE_TIMESTAMP AS“上次更新”
从
QSYS2.SYSPARTITIONSTAT
在哪里
SYSTEM_TABLE_SCHEMA = 'XYZLIB' 和
SYSTEM_TABLE_NAME = 'XYZFILE'
并且 SOURCE_TYPE 不为空
订购依据
LAST_SOURCE_UPDATE_TIMESTAMP
This query runs on IBM i 7.4, but should work for some earlier releases as well.
SELECT
SYSTEM_TABLE_SCHEMA AS "Lib",
SYSTEM_TABLE_NAME AS "File",
SYSTEM_TABLE_MEMBER AS "Member",
SOURCE_TYPE AS "SrcType",
TO_CHAR(NUMBER_ROWS,'999G999G999G999') AS "Record",
TO_CHAR(DATA_SIZE,'999G999G999G999') AS "Size",
PARTITION_TEXT AS "Text",
CREATE_TIMESTAMP AS "CreatedDate",
LAST_SOURCE_UPDATE_TIMESTAMP AS "LastUpdated"
FROM
QSYS2.SYSPARTITIONSTAT
WHERE
SYSTEM_TABLE_SCHEMA = 'XYZLIB' and
SYSTEM_TABLE_NAME = 'XYZFILE'
AND SOURCE_TYPE IS NOT NULL
ORDER BY
LAST_SOURCE_UPDATE_TIMESTAMP