Skip to content

Commit 9fe4f05

Browse files
authored
Merge pull request #314 from janfh/feature/record_locks
2 parents 7c3cefe + aab88e1 commit 9fe4f05

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@
382382
"title": "Get Object Locks",
383383
"category": "Db2 for i"
384384
},
385+
{
386+
"command": "vscode-db2i.getRecordLocks",
387+
"title": "Get Record Locks",
388+
"category": "Db2 for i"
389+
},
385390
{
386391
"command": "vscode-db2i.clearData",
387392
"title": "Clear...",
@@ -1007,6 +1012,11 @@
10071012
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
10081013
"group": "db2workWith@5"
10091014
},
1015+
{
1016+
"command": "vscode-db2i.getRecordLocks",
1017+
"when": "viewItem == table",
1018+
"group": "db2workWith@6"
1019+
},
10101020
{
10111021
"command": "vscode-db2i.clearData",
10121022
"when": "viewItem == table",

src/views/schemaBrowser/contributes.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
"title": "Get Object Locks",
6060
"category": "Db2 for i"
6161
},
62+
{
63+
"command": "vscode-db2i.getRecordLocks",
64+
"title": "Get Record Locks",
65+
"category": "Db2 for i"
66+
},
6267
{
6368
"command": "vscode-db2i.clearData",
6469
"title": "Clear...",
@@ -182,6 +187,11 @@
182187
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
183188
"group": "db2workWith@5"
184189
},
190+
{
191+
"command": "vscode-db2i.getRecordLocks",
192+
"when": "viewItem == table",
193+
"group": "db2workWith@6"
194+
},
185195
{
186196
"command": "vscode-db2i.clearData",
187197
"when": "viewItem == table",

src/views/schemaBrowser/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Configuration from "../../configuration";
1010
import Types from "../types";
1111
import Statement from "../../database/statement";
1212
import { getCopyUi } from "./copyUI";
13-
import { getAdvisedIndexesStatement, getIndexesStatement, getMTIStatement, getAuthoritiesStatement, getObjectLocksStatement } from "./statements";
13+
import { getAdvisedIndexesStatement, getIndexesStatement, getMTIStatement, getAuthoritiesStatement, getObjectLocksStatement, getRecordLocksStatement } from "./statements";
1414
import { BasicSQLObject } from "../../types";
1515

1616
const viewItem = {
@@ -228,6 +228,17 @@ export default class schemaBrowser {
228228
}
229229
}),
230230

231+
vscode.commands.registerCommand(`vscode-db2i.getRecordLocks`, async (object: SQLObject) => {
232+
if (object) {
233+
const content = getRecordLocksStatement(object.schema, object.name);
234+
vscode.commands.executeCommand(`vscode-db2i.runEditorStatement`, {
235+
content,
236+
qualifier: `statement`,
237+
open: false,
238+
});
239+
}
240+
}),
241+
231242
vscode.commands.registerCommand(`vscode-db2i.advisedIndexes`, async (object: SQLObject | SchemaItem) => { //table
232243
if (object) {
233244
let content: string | undefined;

src/views/schemaBrowser/statements.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,23 @@ export function getObjectLocksStatement(schema: string, table: string, objectTyp
300300
sql += ` and sql_object_type = '${objectType.toUpperCase()}'`;
301301
}
302302
return sql;
303+
}
304+
305+
export function getRecordLocksStatement(schema: string, table: string): string {
306+
return `
307+
select
308+
relative_record_number "RRN",
309+
qsys2.delimit_name(table_partition) "Member",
310+
lock_status "Lock Status",
311+
lock_state "Lock Request Type",
312+
substr(job_name,locate_in_string(job_name,'/',-1)+1) "Job Name",
313+
substr(job_name,locate_in_string(job_name,'/',1)+1, locate_in_string(job_name,'/',-1)-locate_in_string(job_name,'/',1)-1) "Job User",
314+
substr(job_name,1, locate_in_string(job_name,'/',1)-1) "Job Number",
315+
thread_id "Thread",
316+
lock_space_id "Lock Space",
317+
lock_scope "Scope"
318+
from qsys2.record_lock_info
319+
where table_schema = '${schema}'
320+
and table_name = '${table}'
321+
`;
303322
}

0 commit comments

Comments
 (0)