When passing temp table around, there is another … solution…

10 Nov

If you are having a hard time dealing with temporary table in following scenarios:

  • Constantly ask whether or not I’m running on the server side or client side, and make sure to validate the case
  • Want to use temporary table as a parameter
  • Temporary Table becomes blank, etc

There is a solution. You can use container with pack and unpack that will allow you pass data around without worries of losing data.

TmpABC tmpABC;
TmpABC tmpABCNew;
Set records;
SetIterator recordsIterator;
container packed;

// Create a couple of records in TmpABC
// ————————————
tmpABC.RefRecId = 1234;
tmpABC.OldValue = ABC::B;
tmpABC.Value = ABC::C;

tmpABC.RefRecId = 4321;
tmpABC.OldValue = ABC::A;
tmpABC.Value = ABC::None;

// Put them into a set and pack the set into a container
// —————————————————–

records = new Set(Types::Record);
while select tmpABC

packed = records.pack();

// Create a set iterator and use the container
// created from the pack
// ——————————————-
recordsIterator = new SetIterator(Set::create(packed));

// Create new records from the record in the set iterator
// ——————————————————

while (recordsIterator.more())

// Show the XML version of the records to make sure
// that the data has been included
// ————————————————
while select tmpABCNew

Leave a comment

Posted by on November 10, 2013 in Development


Tags: , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: