你可以用变量代替数字。
我没有权限无法查看数据,需要知道URL中playerID的总数。
// Variable setting, Total Row of PlayerID's Number.
let Id = FieldValue('playerId', 1);
//or
let Id = total number;
// Loop Start
for start = 1 to $(ID)
// exampleQuery
RestConnectorMasterTable:
SQL SELECT
"__KEY_...."
(SELECT ....
FROM ...)
FROM XML ...
WITH CONNECTION(Url "http://api.football-api.com/2.0/player/$(start)?Authorization=0123456789");
/* put a variable instead of ID's number in the WITH CONNECTION statement. */
// Loop End
Next start;
Play:
Load *
Resident RestConnectorMasterTable
Where Not IsNull([__FK_...]);
Drop table RestConnectorMasterTable;
希望对你有帮助:)
---- 附加 ----
我检查了 api。
简单地运行从 1 到 number 的循环将导致 404 错误。
(不存在的参数)
您需要 9002 团队的 player_id 吗?
如果是这样,可以在 root 下找到 9002 团队的 player_id。
(休息连接→选择要加载的数据→根>小队)
因此,可以先获取小队表的 id 字段,然后在 id 上循环。
第 1 步)
将 Rest 连接器连接到 team API。
http://api.football-api.com/2.0/team/9002?Authorization=1234567890
团队的参数是9002。
第 2 步)
点击Select data to load选择root下的小队数据。
并且只有 id 字段进入了小队表。 (共 28 行)
enter image description here
stpe 3)
在现有的 player_id RestConnector 选项中将分页类型设置为 Custom。
(创建了WITH CONNECTION STATEMENT。)
enter image description here
第 4 步)
请参阅下面的脚本并执行加载。
// Team API Connect
LIB CONNECT TO 'Football_Team';
RestConnectorMasterTable:
SQL SELECT
"__KEY_root",
(SELECT
"id",
"name",
"__FK_squad"
FROM "squad" FK "__FK_squad")
FROM JSON (wrap on) "root" PK "__KEY_root";
[squad]:
LOAD [id] AS [id],
[name] AS [name]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__FK_squad]);
DROP TABLE RestConnectorMasterTable;
// Player_Id API Connect
LIB CONNECT TO 'Football_playerId';
LET total = NoOfRows('squad'); // Number of total.
For i = 0 to $(total) - 1
LET vID = Peek('id', $(i), 'squad'); // Loop start id by 9002 team.
// The following default script was commented out unnecessarily.
// Action required: Implement the logic to retrieve the total records from the REST source and assign to the 'total' local variable.
// Let total = 0;
// Let totalfetched = 0;
// Let startAt = 0;
// Let pageSize = 100;
// for startAt = 0 to total step pageSize
RestConnectorMasterTable:
SQL SELECT
"id" AS "id_u3",
"common_name",
"name" AS "name_u3",
"firstname",
"lastname",
"team",
"teamid",
"nationality",
"birthdate",
"age",
"birthcountry",
"birthplace",
"position",
"height",
"weight",
"__KEY_root"
FROM JSON (wrap on) "root" PK "__KEY_root"
WITH CONNECTION(Url "http://api.football-api.com/2.0/player/$(vID)?Authorization=0123456789");
// player/id? → Change the ID to a variable. *****
// Action required: change URL included in 'WITH CONNECTION' as needed to support pagination for the REST source.
// Please see the documentation for "Loading paged data."
// NEXT startAt;
[Player]:
LOAD [id_u3] AS [id_u3],
[common_name] AS [common_name],
[name_u3] AS [name_u3],
[firstname] AS [firstname],
[lastname] AS [lastname],
[team] AS [team],
[teamid] AS [teamid],
[nationality] AS [nationality],
[birthdate] AS [birthdate],
[age] AS [age],
[birthcountry] AS [birthcountry],
[birthplace] AS [birthplace],
[position] AS [position],
[height] AS [height],
[weight] AS [weight]
// , [__KEY_root] AS [__KEY_root]
RESIDENT RestConnectorMasterTable
WHERE NOT IsNull([__KEY_root]);
DROP TABLE RestConnectorMasterTable;
Next i; // Loop End.
DROP TABLE squad; // id info table delete.
听听结果:
enter image description here
希望你得到你想要的结果:D