Skip to content
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@
"title": "Get Object Locks",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.getRecordLocks",
"title": "Get Record Locks",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.clearData",
"title": "Clear...",
Expand Down Expand Up @@ -1002,6 +1007,11 @@
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
"group": "db2workWith@5"
},
{
"command": "vscode-db2i.getRecordLocks",
"when": "viewItem == table",
"group": "db2workWith@6"
},
{
"command": "vscode-db2i.clearData",
"when": "viewItem == table",
Expand Down
10 changes: 10 additions & 0 deletions src/views/schemaBrowser/contributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@
"title": "Get Object Locks",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.getRecordLocks",
"title": "Get Record Locks",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.clearData",
"title": "Clear...",
Expand Down Expand Up @@ -182,6 +187,11 @@
"when": "viewItem == table || viewItem == view || viewItem == alias || viewItem == function || viewItem == variable || viewItem == index || viewItem == procedure || viewItem == sequence || viewItem == package || viewItem == trigger || viewItem == type",
"group": "db2workWith@5"
},
{
"command": "vscode-db2i.getRecordLocks",
"when": "viewItem == table",
"group": "db2workWith@6"
},
{
"command": "vscode-db2i.clearData",
"when": "viewItem == table",
Expand Down
13 changes: 12 additions & 1 deletion src/views/schemaBrowser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Configuration from "../../configuration";
import Types from "../types";
import Statement from "../../database/statement";
import { getCopyUi } from "./copyUI";
import { getAdvisedIndexesStatement, getIndexesStatement, getMTIStatement, getAuthoritiesStatement, getObjectLocksStatement } from "./statements";
import { getAdvisedIndexesStatement, getIndexesStatement, getMTIStatement, getAuthoritiesStatement, getObjectLocksStatement, getRecordLocksStatement } from "./statements";
import { BasicSQLObject } from "../../types";

const viewItem = {
Expand Down Expand Up @@ -228,6 +228,17 @@ export default class schemaBrowser {
}
}),

vscode.commands.registerCommand(`vscode-db2i.getRecordLocks`, async (object: SQLObject) => {
if (object) {
const content = getRecordLocksStatement(object.schema, object.name);
vscode.commands.executeCommand(`vscode-db2i.runEditorStatement`, {
content,
qualifier: `statement`,
open: false,
});
}
}),

vscode.commands.registerCommand(`vscode-db2i.advisedIndexes`, async (object: SQLObject | SchemaItem) => { //table
if (object) {
let content: string | undefined;
Expand Down
19 changes: 19 additions & 0 deletions src/views/schemaBrowser/statements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,23 @@ export function getObjectLocksStatement(schema: string, table: string, objectTyp
sql += ` and sql_object_type = '${objectType.toUpperCase()}'`;
}
return sql;
}

export function getRecordLocksStatement(schema: string, table: string): string {
return `
select
relative_record_number "RRN",
table_partition "Member",
lock_status "Lock Status",
lock_state "Lock Request Type",
substr(job_name,locate_in_string(job_name,'/',-1)+1) "Job Name",
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",
substr(job_name,1, locate_in_string(job_name,'/',1)-1) "Job Number",
thread_id "Thread",
lock_space_id "Lock Space",
lock_scope "Scope"
from qsys2.record_lock_info
where table_schema = '${schema}'
and table_name = '${table}'
`;
}
Loading