Skip to content

Commit 79d98c0

Browse files
committed
Move statement execution and ui stuff outside of rpg codegen function
1 parent 2515d80 commit 79d98c0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/views/results/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { generateSqlForAdvisedIndexes } from "./explain/advice";
1717
import { updateStatusBar } from "../jobManager/statusBar";
1818
import { DbCache } from "../../language/providers/logic/cache";
1919
import { ExplainType } from "../../connection/types";
20-
import { ColumnMetaData } from "@ibm/mapepire-js";
20+
import { ColumnMetaData, QueryResult } from "@ibm/mapepire-js";
2121

2222
export type StatementQualifier = "statement" | "update" | "explain" | "onlyexplain" | "json" | "csv" | "cl" | "sql" | "rpg";
2323

@@ -382,7 +382,11 @@ async function runHandler(options?: StatementInfo) {
382382
vscode.window.showErrorMessage('RPG qualifier only supported for select statements');
383383
} else {
384384
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);
386390
const textDoc = await vscode.workspace.openTextDocument({ language: 'rpgle', content });
387391
await vscode.window.showTextDocument(textDoc);
388392
updateStatusBar({executing: false});
@@ -493,14 +497,10 @@ async function runHandler(options?: StatementInfo) {
493497
}
494498
}
495499

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 {
501501

502502
let content = `**free\n\n`
503-
+ `// statement: ${statement.content}\n\n`
503+
+ `// statement: ${statement}\n\n`
504504
+ `// Row data structure\ndcl-ds row_t qualified template;\n`;
505505

506506
for (let i = 0; i < result.metadata.column_count; i++) {

0 commit comments

Comments
 (0)