查詢腳本我正在創建一個以模態窗口開頭並運行幾個存儲過程並自動連接結果表的腳本。這些是相當大的表,我想為用戶添加一個選項來運行類似於查詢生成器的選項,在這裡他們可以選擇列作為過濾器並輸入他們想要過濾的數據。
在桌子打開之前我該如何做呢?我想最小化運行過程和連接表所花費的時間,因此在最終表打開後過濾數據並不是我想要做的。
任何建議將不勝感激!
Re:查詢腳本對此的一般解決方案將非常複雜。 您可以構建一個包含固定數量選擇的對話框。
// Get numeric column names from sample data
dt = open("$sample_data\Boston Housing.jmp");
col_list = dt << get column names("String", numeric);
insertinto(col_list, "<NO selection="">", 1);
nw = new window("Get Data2",
panel box("Filter Data",
lineup box(ncol(3),
text box("Column"), text box("Low Value"), text box("High Value"),
cb1 = combo box(col_list),
low1 = number edit box(),
high1 = number edit box(),
cb2 = combo box(col_list),
low2 = number edit box(),
high2 = number edit box(),
cb3 = combo box(col_list),
low3 = number edit box(),
high3 = number edit box(),
// Add more columns if needed...
)
)
);</NO>

Re:查詢腳本如果我運行存儲過程,獲得列的完整列表及其數據類型,並以某種方式將它們用作選項,我是否能夠構建過濾器?它最終大約有45列,所以如果有更好的東西請告訴我!
Re:查詢腳本我如何讓用戶選擇過濾器?就像我想打開數據表但我只想在哪裡:長度在20-40之間:尺度為25納摩爾。但我希望用戶能夠從可用列中選擇要應用的過濾器。
Re:查詢腳本您可以向模態窗口添加提示以預過濾數據。 這是一個簡單的示例,允許用戶在查詢運行之前預先選擇產品和位置。 我已經硬編碼了可供選擇的值列表,但理想情況下,您可以使用SQL查詢動態獲取它。
// Hardcode or get dynamically from the database
product_list = {"AAAA", "BBBB", "CCCC", "DDDD"};
// Hardcode or get dynamically from the database
location_list = {"China", "England", "Germany", "Italy", "Japan", "USA"};
nw = new window("Get Data", << modal,
panel box("Pre-Filter",
hlistbox(
product_cb = listbox(product_list),
location_cb = listbox(location_list)
),
),
panel box("Actions",
hlistbox(
button box("OK",
ok_pushed = 1;
selected_products = product_cb << get selected;
selected_locations = location_cb << get selected
),
button box("Cancel",
ok_pushed = 0;
)
)
)
);
if (ok_pushed,
product_in_list = "";
location_in_list = "";
print(selected_products, selected_locations);
if (nitems(selected_products) > 0,
product_in_list = "t.products IN ('" ||
concat items(selected_products, "', '") || "')";
);
if (nitems(selected_locations) > 0,
location_in_list = "t.locations IN ('" ||
concat items(selected_locations, "', '") || "')";
);
print(product_in_list, location_in_list);
// run SQL query
);

日誌輸出:
{"AAAA", "CCCC"}
{"England", "Germany", "Italy"}
"t.products IN ('AAAA', 'CCCC')"
"t.locations IN ('England', 'Germany', 'Italy')"