Yes, you will have to run the function once to get it "updated".
If you want the datatable to be named same as the PartID then you can just use one argument in the function. Here is a bit more complete example with quotes and without quotes version:
Names Default To Here(1);
getDataTable4PartID_withQuotes = Function({PartID},
Open Database("connectionstring",
"
select '" || PartID || "' as value
from dual
",
"PartID"
);
);
partDataTable_withQuotes = getDataTable4PartID_withQuotes("PART16.0009");
Show(partDataTable_withQuotes);
getDataTable4PartID = Function({PartID},
Open Database("connectionstring",
"
select '" || PartID || "' as value
from dual
",
PartID
);
);
partDataTable = getDataTable4PartID("PART16.0009");
Show(partDataTable);
For me these are printed to the log:
partDataTable_withQuotes = DataTable("PartID");
partDataTable = DataTable("PART16.0009");
JMP will return the datatable from the function (as it is the "last" line), but I don't feel comfortable trusting it so I would use local reference in function and then return the reference and the final function would be something like:
getDataTable4PartID = Function({PartID}, {dtTemp},
dtTemp = Open Database("connectionstring",
"select '" || PartID || "' as value
from dual",
PartID
);
return(dtTemp);
);
-Jarmo