zoukankan      html  css  js  c++  java
  • 如何通过.net访问ISeries的多member的Phiscal file两种方式alias ovrdbf

    Using an ALIAS to access a multi-member file
    To use an ALIAS to access a member other than the first member of a file, first create the
    alias, and then use that ALIAS instead of the file name. Example 4-97 shows how to create
    an alias to the second member of file MYFILE, then use that alias to reference the member.
    Example 4-97 Accessing a multi-member file using an ALIAS
    iDB2Command cmd = new iDB2Command("create alias myschema.fileMbr2 for
    myschema.myfile(member2)", cn);
    cmd.ExecuteNonQuery();
    // Now access the second member using the alias we just created
    cmd.CommandText = "select * from myschema.fileMbr2";
    iDB2DataReader dr = cmd.ExecuteReader();
    // Etc.
    Using OVRDBF to access a multi-member file
    You can use the OVRDBF command to temporarily override a multiple-member database file
    as shown in Example 4-98. Using the CallPgm example we create in “A general method for
    invoking QCMDEXC” on page 120, we override the file so that SQL will reference MEMBER2
    instead of the first member in the file. After calling OVRDBF as we show in this example, SQL
    statements that reference the file MYSCHEMA.MYFILE use the second member, MEMBER2.
    Example 4-98 Using OVRDBF to access the second member of a multi-member file
    rc = CallPgm("OVRDBF FILE(MYFILE) TOFILE(MYSCHEMA/MYFILE) MBR(MEMBER2) OVRSCOPE(*JOB)",
    cn);
    // Now a SELECT * FROM MYSCHEMA.MYFILE will access member MEMBER2
    cmd.CommandText = "select * from myschema.myfile";
    iDB2DataReader dr = cmd.ExecuteReader();
    // Etc.
    Processing CL commands that produce an OUTFILE
    Many CL commands provide an option to store the command output into an outfile, which is a
    database file that can be queried using a SQL select statement, just like any other table. In
    Example 4-99 on page 124, we execute a DSPUSRPRF command through QCMDEXC using
    the CallPgm method we created in Example 4-94 on page 121. After running this command,
    we execute a SELECT statement to select all of the user profiles from the table (outfile) that
    was created by DSPUSRPRF. We use a DataReader to read information from the table.
    124 Integrating DB2 Universal Database for iSeries with Microsoft ADO .NET
    Example 4-99 Processing a CL command that produces an OUTFILE
    // Create and open a connection to the iSeries.
    iDB2Connection cn = new
    iDB2Connection("DataSource=myiseries;DefaultCollection=sampledb;");
    cn.Open();
    // Call the CallPgm method to execute the DSPUSRPRF command
    // and tell it to put the output into an OUTFILE.
    bool success = CallPgm("DSPUSRPRF USRPRF(*ALL) OUTPUT(*OUTFILE)
    OUTFILE(SAMPLEDB/USRPRFINFO)", cn);
    // If the call succeeded, open a DataReader to read a list of
    // all the user profiles in the outfile.
    if (success == true)
    {
    iDB2Command cmd = new iDB2Command("SELECT UPUPRF FROM USRPRFINFO", cn);
    iDB2DataReader dr = cmd.ExecuteReader();
    while (dr.Read())
    {
    Console.WriteLine("User profile: " + dr.GetString(0));
    }
    // Close the DataReader since we're done using it.
    dr.Close();
    // Dispose the command since we no longer need it.
    cmd.Dispose();
    }
    // Close the connection since we're done using it.
    cn.Close();

  • 相关阅读:
    Nginx之——日志按日期分割的实现(基于CentOS操作系统)
    git忽略已加入到版本库的文件
    Linux系统下查看已经登录用户并踢出的方法
    nginx代理后,获取request的ip
    Spring Aop 修改目标方法参数和返回值
    nginx防止DDOS攻击配置
    SQL Server 合并复制遇到identity range check报错的解决
    SQL Saturday 北京将于7月25日举办线下活动,欢迎参加
    T-SQL检查停止的复制作业代理,并启动
    揭开SQL注入的神秘面纱PPT分享
  • 原文地址:https://www.cnblogs.com/wildfish/p/214844.html
Copyright © 2011-2022 走看看