nested loop wiht 2 tables break up
Hi,
I want to fill Table_3 with combination of ID's form table_1 and table_2, but the nested loop returns only the 1st record of table_1 with all records of table_2 and then ends ?
To select this combination, I run 2 connects:
$db1 = new Win32::ODBC("DSN=......
$db2 = new Win32::ODBC("DSN=......
Now I define 2 statements:
$db1-> Sql("SELECT id1 FROM tab_1") ;
$db2-> Sql("SELECT id2 FROM tab_2") ;
now running the loop to combine it:
while ( $db1-> FetchRow() ) {
$ID1 = $db1->Data;
while ( $db2-> FetchRow() ) {
$ID2 = $db2->Data;
print "id1, id2 while fetching: $ID1, $ID2 \n";
}
}
it brings this result:
id1, id2 while fetching: 1, 1
id1, id2 while fetching: 1, 2
id1, id2 while fetching: 1, 3
id1, id2 while fetching: 1, 4
id1, id2 while fetching: 1, 5
id1, id2 while fetching: 1, 6
id1, id2 while fetching: 1, 7
id1, id2 while fetching: 1, 8
id1, id2 while fetching: 1, 9
id1, id2 while fetching: 1, 10
but table 1 has 17 records, which are displayed properly, as long I do not loop through the 2nd table !
why does the inner loop stops the outer ?
thanks for any tip ?