Dear Community,
I am building a SQL script where utilizing temporary tables at SQL server. Simplified example script below (which works fine elsewhere) runs without error but does NOT return any data (ie. JMP data table does not pop up).
query= "
CREATE TABLE #tmpTable (ID int PRIMARY KEY NOT NULL, WaferNum int NOT NULL);
INSERT INTO #tmpTable (ID, WaferNum) (
SELECT
ID,
WaferNum
FROM WareHouse
);
SELECT * FROM #tmpTable;
DROP TABLE #tmpTable;
";
dbc = Create Database Connection(
"DSN=DatabaseName; ... ; UID=email@abc.com;"
);
Execute SQL (dbc, query);
close database connection(dbc);
My next iteration was to split the execution as below; this trick was mentioned on some thread.
query1= "
CREATE TABLE #tmpTable (ID int PRIMARY KEY NOT NULL, WaferNum int NOT NULL);
INSERT INTO #tmpTable (ID, WaferNum) (
SELECT
ID,
WaferNum
FROM WareHouse
);
";
query2= "
SELECT * FROM #tmpTable
DROP TABLE #tmpTable;
";
query3= "
DROP TABLE #tmpTable;
";
dbc = Create Database Connection(
"DSN=DatabaseName; ... ; UID=email@abc.com;"
);
Execute SQL (dbc, query1);
Execute SQL (dbc, query2, "Table");
Execute SQL (dbc, query3);
close database connection(dbc);
Now JMP log window captures messages from SQL server (without returned data): Invalid object name #tmpTable and Cannot drop the table #tmpTable as does not exist.
I am running JMP16. Any advices are highly appreciated.