左結合を使用して do while ループの結果を要約していますが、なんらかの理由でテーブルを結合せず、単に上書きしています。見えないのは何ですか?
DO WHILE counter < NbContracts
SELECT depot_nr as depot_nr;
WHERE rownum = counter FROM test3
test33(depot_nr, counter)
counter = counter + 1
ENDDO
CLOSE TABLES
PROCEDURE test33(depot_nr_in, NbofTimes)
USE bs_case alias bs
SELECT jaar as jaar,;
Psres4pcgb as &depot_nr_in;
WHERE Depot_nr = depot_nr_in FROM bs
COPY TO toJoin.dbf
DO CASE
CASE NbofTimes = 1
SELECT * FROM toJoin.dbf
COPY TO joining.dbf
CASE NbofTimes = NbContracts
SELECT * FROM bsP.tmp as one LEFT JOIN joining.dbf as aggregated;
ON (one.depot_nr = aggregated.depot_nr) into table final.dbf
CLOSE TABLES
ENDPROC
OTHERWISE
SELECT &depot_nr_in FROM toJoin.dbf as a LEFT JOIN joining.dbf as b;
ON a.jaar = b.jaar INTO TABLE final.dbf
CLOSE TABLES
USE final.dbf
COPY TO joining.dbf
ENDCASE
CLOSE TABLES
CLOSE DATABASES
ENDPROC
問題は OTHERWISE セクションに表示され (私は思う)、別の不明な理由で、FoxPro が CASE 構造を認識していません (ボーナスの質問ですが、優先度は低くなります)。
私が欲しいものの小さなイラスト
test3.dbf
===================================
22
31
32
23
NbofTimes = 1
final.dbf
===================================
year 22
-----------------------------------
1 val1
2 val2
3 val3
... ...
80 val80
NbofTimes = 2
final.dbf
===================================
year 22 31
-----------------------------------
1 val1 val4
2 val2 val5
3 val3 val6
... ... ...
80 val80 val81
NbofTimes = 3
final.dbf
===================================
year 22 31 32
-----------------------------------
1 val1 val4 val7
2 val2 val5 val8
3 val3 val6 val9
... ... ... ...
80 val80 val81 val82
NbofTimes = 4
final.dbf
===================================
year 22 31 32 23
-----------------------------------
1 val1 val4 val7 val10
2 val2 val5 val8 val11
3 val3 val6 val9 val12
... ... ... ... ...
80 val80 val81 val82 val83
今何が起こっているかというと、私の最終的なテーブルは決して大きくならず、最後の反復だけが含まれています。ヘルプ.....