@@ -17,7 +17,7 @@ import { generateSqlForAdvisedIndexes } from "./explain/advice";
17
17
import { updateStatusBar } from "../jobManager/statusBar" ;
18
18
import { DbCache } from "../../language/providers/logic/cache" ;
19
19
import { ExplainType } from "../../connection/types" ;
20
- import { ColumnMetaData } from "@ibm/mapepire-js" ;
20
+ import { ColumnMetaData , QueryResult } from "@ibm/mapepire-js" ;
21
21
22
22
export type StatementQualifier = "statement" | "update" | "explain" | "onlyexplain" | "json" | "csv" | "cl" | "sql" | "rpg" ;
23
23
@@ -382,7 +382,11 @@ async function runHandler(options?: StatementInfo) {
382
382
vscode . window . showErrorMessage ( 'RPG qualifier only supported for select statements' ) ;
383
383
} else {
384
384
chosenView . setLoadingText ( `Executing SQL statement...` , false ) ;
385
- let content : string = await statementToRpgDs ( statementDetail ) ;
385
+ setCancelButtonVisibility ( true ) ;
386
+ updateStatusBar ( { executing : true } ) ;
387
+ const result = await JobManager . runSQLVerbose ( statementDetail . content , undefined , 1 ) ;
388
+ setCancelButtonVisibility ( false ) ;
389
+ let content : string = await statementToRpgDs ( result , statementDetail . content ) ;
386
390
const textDoc = await vscode . workspace . openTextDocument ( { language : 'rpgle' , content } ) ;
387
391
await vscode . window . showTextDocument ( textDoc ) ;
388
392
updateStatusBar ( { executing : false } ) ;
@@ -493,14 +497,10 @@ async function runHandler(options?: StatementInfo) {
493
497
}
494
498
}
495
499
496
- async function statementToRpgDs ( statement : ParsedStatementInfo ) : Promise < string > {
497
- setCancelButtonVisibility ( true ) ;
498
- updateStatusBar ( { executing : true } ) ;
499
- const result = await JobManager . runSQLVerbose ( statement . content , undefined , 1 ) ;
500
- setCancelButtonVisibility ( false ) ;
500
+ function statementToRpgDs ( result : QueryResult < any > , statement : string ) : string {
501
501
502
502
let content = `**free\n\n`
503
- + `// statement: ${ statement . content } \n\n`
503
+ + `// statement: ${ statement } \n\n`
504
504
+ `// Row data structure\ndcl-ds row_t qualified template;\n` ;
505
505
506
506
for ( let i = 0 ; i < result . metadata . column_count ; i ++ ) {
0 commit comments