I find that you often need to create and manipulate standalone rowsets. Sometimes you can get the data for your standalone rowset from the database using the Fill method, however sometimes you'll want to copy from existing rowsets. This is where the CopyTo method comes in handy.

However there is one important thing to note when using CopyTo - it will only copy like-named record fields and subscrolls at corresponding levels

In order to work correctly, the record in the source rowset must have the same name as the record in target rowset, unless you specify a record list in the parameters.

For instance, say I have data in a rowset &rsExample with one record, EXAMPLE which is populated in the component buffer.

The EXAMPLE record has the following fields:

  • EMPLID
  • NAME

Now, say I want to copy the data from my rowset &rsExample to another rowset, &rsExampleAudit which consists of an audit record forEXAMPLE called AUDIT_EXAMPLE.

The AUDIT_EXAMPLE record has the following fields:

  • AUDIT_OPRID
  • AUDIT_STAMP
  • AUDIT_ACTN
  • EMPLID
  • NAME

What I want is to copy the like-name fields between &rsExample and &rsExampleAudit (the fields EMPLID and NAME).

The following code will NOT work:

&rsExample.CopyTo(&rsExampleAudit)

Why? Because &rsExample consists of a record named EXAMPLE, but &rsExampleAudit consists of a record named AUDIT_EXAMPLE. Because the two rowsets do not have the same underlying record name, the copy does absolutely nothing (quite frustrating!).

In this scenario, we need to specify a record list, so it knows the source and target record names. This how I need to write this code to make it work:

&rsExample.CopyTo(&rsExampleAudit, Record.EXAMPLE, Record.AUDIT_EXAMPLE)

Generically the syntax is:

&rsSource.CopyTo(&rsTarget, Record.SOURCE_RECNAME, Record.TARGET_RECNAME)

Copying Rowsets的更多相关文章

  1. 14——小心copying行为

    资源的copying行为决定对象的copying行为. 抑制copying行为,使用引用计数.

  2. UVa 714 Copying Books(二分)

    题目链接: 传送门 Copying Books Time Limit: 3000MS     Memory Limit: 32768 KB Description Before the inventi ...

  3. Effective C++ -----条款14: 在资源管理类中小心copying行为

    复制RAII对象必须一并复制它所管理的资源,所以资源的copying行为决定RAII对象的copying行为. 普遍而常见的RAII class copying行为是:抑制copying(使用私有继承 ...

  4. ACM: Copying Data 线段树-成段更新-解题报告

    Copying Data Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Description W ...

  5. 抄书 Copying Books UVa 714

    Copying  Books 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/B 题目: Descri ...

  6. Copying Fields to a new Record

    This is a time saving tip for application designer. If you are creating a new record definition and ...

  7. UVA 714 Copying Books 二分

    题目链接: 题目 Copying Books Time limit: 3.000 seconds 问题描述 Before the invention of book-printing, it was ...

  8. poj 1505 Copying Books

    http://poj.org/problem?id=1505 Copying Books Time Limit: 3000MS   Memory Limit: 10000K Total Submiss ...

  9. [Effective C++ --014]在资源管理类中小心copying行为

    第一节 <背景> 条款13中讲到“资源取得的时机便是初始化时机”并由此引出“以对象管理资源”的概念.通常情况下使用std中的auto_ptr(智能指针)和tr1::shared_ptr(引 ...

随机推荐

  1. WebService中实现上传下载文件

    不多说,直接看代码: /*上传文件的WebService*/ using System; using System.Collections; using System.Collections.Gene ...

  2. HTML5 规范

    1.内容类型(ContentType) HTML5扩展仍然为".html"或".htm",内容类型(ContentType)仍然为"text/html ...

  3. struts2访问servlet API

    搭建环境: 引入jar包,src下建立struts.xml文件 项目配置文件web.xml. web.xml: <?xml version="1.0" encoding=&q ...

  4. Python 之字节转换

    # coding: utf-8 def bytes2human(n): """ >>> bytes2human(10000) 9K >>&g ...

  5. 编译 proto 文件到指定语言的代码

    由于 Protocol Buffers 3 的正式版还没有发布,在官网(https://developers.google.com/protocol-buffers/docs/downloads)目前 ...

  6. unity3d学习重点记录

    本文主要是记录在学习unity3d中遇到的重点功能的实现,以及一些API的使用方法.以便在以后使用到的时候查找. 1,给一个UIButton添加执行的事件 // Use this for initia ...

  7. Select的深入应用(2)

    首先创建两张表. 全连接 全连接:在检索时指定多个表,将每个表用逗号分隔,这样每个表的数据行都和其他表的每行交叉产生所有可能的组合,这样就是一个全连接.所有可能的组和数即每个表的行数的乘积. 或者: ...

  8. oracle的sqlldr并行导入表不要加索引

    ORA-26002: Table string has index defined upon it. Cause: Parallel load was specified into a table w ...

  9. 华为OJ平台——尼科彻斯定理

    题目描述: 验证尼科彻斯定理,即:任何一个整数m的立方都可以写成m个连续奇数之和. 例如: 1^3=1 2^3=3+5 3^3=7+9+11 4^3=13+15+17+19 输入 输入一个int整数 ...

  10. MacOSX和Windows 8的完美融合

    MacOSX和Windows8的完美融合 一般情况下我们要在MACOS系统下运行Windows软件怎么办呢?一种方法我们可以装CrossOver这款软件,然后在configuration->in ...