| 48 |
|
|
| 49 |
} |
} |
| 50 |
|
|
| 51 |
} elseif (i in column_with_dependency) { |
} else { |
| 52 |
# Check for cases where a possible foreign key value has a dependency |
# Check for cases where a possible foreign key value has a dependency |
| 53 |
|
if (column_with_dependency == i) { |
|
# Check to see if the value is one of the old increments |
|
|
if (csv[i] in increment_pairs) { |
|
| 54 |
|
|
| 55 |
# Check to see if the dependencies match up |
# Check to see if the value is one of the old increments |
| 56 |
dependency_pattern_found = 1; |
if (csv[i] in increment_pairs) { |
|
dependency_match = 0; |
|
|
for (n = 0; n < num_fields; n++) { |
|
|
if (n in column_dependency) { |
|
|
if (csv[n] != column_dependency[n]) { |
|
|
# Unset found if there is even one case of failure |
|
|
dependency_pattern_found = 0; |
|
|
} else { |
|
|
# Because we're setting found to default to true, |
|
|
# we need to ensure we really did find any values at all |
|
|
dependency_match = 1; |
|
|
} |
|
|
} |
|
|
} |
|
| 57 |
|
|
| 58 |
# Now check to see if we really found anything |
# Check to see if the dependencies match up |
| 59 |
if (dependency_pattern_found == 1 && dependency_match == 1) { |
dependency_pattern_found = 1; |
| 60 |
pattern_found = 1; |
dependency_match = 0; |
| 61 |
|
for (n = 0; n < num_fields; n++) { |
| 62 |
|
if (n in column_dependency) { |
| 63 |
|
if (csv[n] != column_dependency[n]) { |
| 64 |
|
# Unset found if there is even one case of failure |
| 65 |
|
dependency_pattern_found = 0; |
| 66 |
|
} else { |
| 67 |
|
# Because we're setting found to default to true, |
| 68 |
|
# we need to ensure we really did find any values at all |
| 69 |
|
dependency_match = 1; |
| 70 |
|
} |
| 71 |
|
} |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
# Now check to see if we really found anything |
| 75 |
|
if (dependency_pattern_found == 1 && dependency_match == 1) { |
| 76 |
|
pattern_found = 1; |
| 77 |
|
|
| 78 |
|
# Replace the value |
| 79 |
|
printf "%s,", increment_pairs[csv[i]]; |
| 80 |
|
} |
| 81 |
|
|
|
# Replace the value |
|
|
printf "%s,", increment_pairs[csv[i]]; |
|
| 82 |
} |
} |
| 83 |
|
|
| 84 |
} |
} |
|
|
|
| 85 |
} |
} |
| 86 |
|
|
| 87 |
# If there were no matches, just keep the existing data |
# If there were no matches, just keep the existing data |