|
|
|
|
|
|
|
|
noprerequisites : true |
|
|
noprerequisites : true |
|
|
, cmdFn : function(args){ |
|
|
, cmdFn : function(args){ |
|
|
|
|
|
|
|
|
// PB : TODO -- Load loopback app !!! for ds |
|
|
|
|
|
var sqlquery = fs.readFileSync(args._[1], { encoding: 'utf8'}) |
|
|
|
|
|
sqlquery = PATTERNAPI.includesql(sqlquery, path.dirname(args._[1])).then(sqlquery => { |
|
|
|
|
|
sqlquery = " DECLARE @dsql NVARCHAR(MAX) = ' \r\n" + sqlquery.replace(/\'/g,"''") |
|
|
|
|
|
fs.writeFileSync(args._[1].replace('.sql', '.d.temp.sql'), sqlquery, { encoding: 'utf8'}) // For intermediate processing |
|
|
|
|
|
fs.writeFileSync(args._[1].replace('.sql', '.d.sql'), sqlquery + "\r\n'" + " EXEC sp_executesql @dsql" , { encoding: 'utf8'}) // Dynamic query output. |
|
|
|
|
|
|
|
|
// PB : TODO -- Load loopback app !!! for db connection to execute intermediate results for query genereation !!! |
|
|
|
|
|
|
|
|
|
|
|
return PATTERNAPI.includesql('', args._[1]).then(sqlquery => { |
|
|
|
|
|
// Do what we need to with the output |
|
|
|
|
|
// fs.writeFileSync(args._[1].replace('.sql', '.temp.g.sql'), sqlquery, { encoding: 'utf8'}) // For intermediate processing |
|
|
|
|
|
fs.writeFileSync(args._[1].replace('.i', ''), sqlquery + "\n" , { encoding: 'utf8'}) // Dynamic query output. |
|
|
|
|
|
// Static query debug output cannot be produced here... As EXEC sp_executesql must run to get the output. This can be produced by sqlfragmentexec in sql command mode. |
|
|
return sqlquery |
|
|
return sqlquery |
|
|
}) |
|
|
}) |
|
|
|
|
|
|