cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Neo
Neo
Level VI

What is wrong in my function call?

I am learning how to write and call a functions in JMP (coming from Matlab).

Trying to pull data for a tested part from database via a SQL query.

Wrote two separate scripts. One is a function with PartID as the input variable and the test data table as output.

Other script is the function call, but I do not seem to be able to pass the partID to the function. Where I am going wrong?

 

My function call

partDataTable = getDataTable4partID("PART16.0009")

My function

getDataTable4PartID = Function( {PartID},{partDataTable}, 
Open Database(
		"Driver=SQL Server;
		Server=XAB-SQL02;
		DATABASE=TBSDF;
		Trusted_Connection=Yes;",
		"SELECT * FROM dbo.View_BBX a WHERE a.Part like 'PartID' AND a.TestDateTime > '2021-02-01'",
		"partDataTable" // name of the output data table
    );
    
);

The SQL query itself works when PartID is replaced by the actual part number PART16.0009 and run separately spitting the desired data table, but when I use the function call, the data table still has 'PartID' in the Source/ Update From DB scripts in the empty data table. 

 

When it's too good to be true, it's neither
11 REPLIES 11
Neo
Neo
Level VI

Re: What is wrong in my function call?

Thanks @jthi . All my scripts and functions have the first line as

Names Default To Here(1);

It just happens (as mentioned in my previous post), this particular function did not run without commenting the above line. 

In any case, if I use your suggested function, I get a data table with expected/correct data but the data table is called UntitledXX (XX happens to be 24 in my case). Any help to fix this would be very helpful. Thanks.

When it's too good to be true, it's neither
Neo
Neo
Level VI

Re: What is wrong in my function call?

Adding 

include ("getDataTable4partID.jsl");

before the function call seems to have solved all the issues I have ben having.

When it's too good to be true, it's neither