I have this method for a test query (SQl Server 2005):
function _SQL_Test()
{
var sql = "DECLARE @RC INT SET @RC = 1 SELECT @RC";
var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), sql, null, 1);
application.output(dataset.getValue(1,1));
}
But the dataset variable always returns null. With my SQL client I receive a dataset (1 row, 1 column), so the sql syntax is OK. Where is the issue?
log-out:
But rawSQL doesn’t return anything, only true or false
The SQL code you are trying to run needs to be a stored procedure. Then check out the sample code to rawSQL.executeStoredProcedure. The rawSQL plugin returns a dataset when executing a store procedure.
My guess is that as simple as it is, it has 2 statements in it. If you need to run a string of SQL commands that depend on each other or if you need to return data from the rawSQL plugin, the stored procedure approach is the way to go.