-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexcelDbExample3.awk
More file actions
63 lines (48 loc) · 1.25 KB
/
Copy pathexcelDbExample3.awk
File metadata and controls
63 lines (48 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Creates a Pivot Table:
BEGIN {
# These can also be specified on the command line.
IT = "excel:sheet=real_estate";
FS = "[\t]";
loadArray(querySql, "customer_sql.xml");
# Use sorted array.
createSortedArray(zips);
}
# Skip headers
(FNR == 1) {
next;
}
# Check for empty line
($0 == "null") {
next;
}
# else
{
zips[$3]++;
}
END {
# Use dynamic sql.
sql = "SELECT * FROM customer WHERE zip IN (";
first = 1;
for (i in zips) {
if (!first) {
sql = sql ",";
}
first = 0;
sql = sql i;
}
sql = sql ")";
querySql["sqlQuery"] = sql;
# Tell compiler that this is an array.
customer[0];
# Use sorted array.
createSortedArray(customer);
# Find database entries with zip codes that are in the excel file.
statementHandle = queryDatabase(querySql, outArrays);
for (i in outArrays) {
copyArray(customer, outArrays[i]);
print customer;
}
if (statementHandle != "") {
closeDatabaseStatement(statementHandle);
}
}