Skip to content

Commit 83682da

Browse files
committed
Support for QTEMP/session
Signed-off-by: worksofliam <[email protected]>
1 parent c3badb5 commit 83682da

File tree

3 files changed

+40
-7
lines changed

3 files changed

+40
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-db2i",
33
"displayName": "Db2 for IBM i",
44
"description": "Db2 for IBM i tools in VS Code",
5-
"version": "1.6.3-scott11",
5+
"version": "1.6.3-scott12",
66
"engines": {
77
"vscode": "^1.95.0"
88
},

src/database/table.ts

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,38 @@ export default class Table {
3030
` column.table_schema = key.table_schema and`,
3131
` column.table_name = key.table_name and`,
3232
` column.column_name = key.column_name`,
33-
`WHERE column.TABLE_SCHEMA = '${schema}' AND column.TABLE_NAME = '${name}'`,
33+
`WHERE column.TABLE_SCHEMA = ? AND column.TABLE_NAME = ?`,
3434
`ORDER BY column.ORDINAL_POSITION`,
3535
].join(` `);
3636

37-
return JobManager.runSQL(sql);
37+
return JobManager.runSQL(sql, {parameters: [schema, name]});
38+
}
39+
40+
/**
41+
* This is to be used instead of getItems when the table is in session/QTEMP
42+
*/
43+
static async getSessionItems(name: string): Promise<TableColumn[]> {
44+
const sql = [
45+
`SELECT `,
46+
` column.TABLE_SCHEMA,`,
47+
` column.TABLE_NAME,`,
48+
` column.COLUMN_NAME,`,
49+
` '' as CONSTRAINT_NAME,`,
50+
` column.DATA_TYPE, `,
51+
` column.CHARACTER_MAXIMUM_LENGTH,`,
52+
` column.NUMERIC_SCALE, `,
53+
` column.NUMERIC_PRECISION,`,
54+
` column.IS_NULLABLE, `,
55+
` column.HAS_DEFAULT, `,
56+
` column.COLUMN_DEFAULT, `,
57+
` column.COLUMN_TEXT, `,
58+
` column.IS_IDENTITY`,
59+
`FROM QSYS2.SYSCOLUMNS2_SESSION as column`,
60+
`WHERE column.TABLE_NAME = ?`,
61+
`ORDER BY column.ORDINAL_POSITION`,
62+
].join(` `);
63+
64+
return JobManager.runSQL(sql, {parameters: [name]});
3865
}
3966

4067
static async isPartitioned(schema: string, name: string): Promise<boolean> {

src/views/results/resultSetPanelProvider.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,16 @@ export class ResultSetPanelProvider implements WebviewViewProvider {
194194

195195
const isPartitioned = await Table.isPartitioned(goodSchema, goodName);
196196
if (!isPartitioned) {
197-
const tableInfo = await Table.getItems(
198-
goodSchema,
199-
goodName
200-
);
197+
let tableInfo: TableColumn[] = [];
198+
199+
if ([`SESSION`, `QTEMP`].includes(goodSchema)) {
200+
tableInfo = await Table.getSessionItems(goodName);
201+
} else {
202+
tableInfo = await Table.getItems(
203+
goodSchema,
204+
goodName
205+
);
206+
}
201207

202208
const uneditableTypes = [`VARBIN`, `BINARY`, `ROWID`, `DATALINK`, `DBCLOB`, `BLOB`, `GRAPHIC`]
203209

0 commit comments

Comments
 (0)