[development-axapta] Pass Data from One Temp Table to another

1) if you only wants to have two temp table variables (which go to the same 
data)

- means if you insert a new record using your first varibale and want to 
"see" select this using the second var, you only have to call .setTmpData() 
on your second var after filling the temp table.

TmpTable    t1;

TmpTable    t2;
;
(insert 10 records in t1)

// select count(recID) from t1; print t1.recid; ==> 10
// select count(recID) from t2; print t2.recid; ==>  0

t2.SetTmpData(t1);

// select count(recID) from t2; print t2.recid; ==> 10

t1.clear();
t1.initvalue();
t1.somefiled = somevalue;
t1.insert();

// select count(recID) from t1; print t1.recid; ==> 11
// select count(recID) from t2; print t2.recid; ==> 11


2) if you want to have two real temp tables with (initially) the same data.

- means after "duplicating" the changes within table 1 shouldn't be visble 
in table 2

you must declare two real different temp cursors and copy the data from the 
first to tehe second after filling


TmpTable    t1;

TmpTable    t2;
;

// select count(recID) from t1; print t1.recid; ==>  0
// select count(recID) from t2; print t2.recid; ==>  0

(insert 10 records in t1)
....

// select count(recID) from t1; print t1.recid; ==> 10
// select count(recID) from t2; print t2.recid; ==>  0

while select * from t1 {
  t2.clear();
  t2.data(t1.data());
  t2.insert();
}

// select count(recID) from t1; print t1.recid; ==> 10
// select count(recID) from t2; print t2.recid; ==> 10

t1.clear();
t1.initvalue();
t1.somefiled = somevalue;
t1.insert();

// select count(recID) from t1; print t1.recid; ==> 11
// select count(recID) from t2; print t2.recid; ==> 10  !!!!!

regards

Douglas

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.