Skip to content

Commit f707c82

Browse files
Merge pull request #92 from codefori/docs/db2i-enhancements
Document Db2i v1.16.0 enhancements
2 parents 4584458 + 15415d6 commit f707c82

7 files changed

Lines changed: 76 additions & 31 deletions

File tree

423 KB
Loading
188 KB
Loading
106 KB
Loading
236 KB
Loading
159 KB
Loading
133 KB
Loading

src/content/docs/extensions/db2i/index.mdx

Lines changed: 76 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The extension can be [installed from the Marketplace](https://marketplace.visual
2020

2121
As of 0.3.0, the Db2 for i extension requires a server component. The component provides improved performance and makes it easy for us to add advanced features. The Db2 for i extension manages the server component installation when you connect to an IBM i with Code for IBM i and will ask the user to confirm any installation or update. The server component is installed into `$HOME/.vscode`, which means a per-user installation. [The server component is also open-source](https://github.com/ThePrez/CodeForIBMiServer)<Icon name="github" class="icon-inline" />.
2222

23-
## Executing statements
23+
## Executing Statements
2424

2525
Either:
2626

@@ -35,49 +35,54 @@ After you have an SQL file open, you can either:
3535
* use the play button in the top right to execute
3636
* use the shortcut (control / command + R) to execute the statement
3737

38-
The result set will appear below the statement. As your scroll through the result set, more data will load. When you execute an SQL statement, it will be prepended to your Query History view, where it remains readily accessible.
38+
The result set will appear below the statement. As your scroll through the result set, more data will load.
3939

40-
SQL statements are executed using the active job selected in the SQL Job Manager view.
40+
SQL statements are executed using the active job selected in the **SQL Job Manager** view.
4141

42-
### SQL prefixes
42+
### SQL Prefixes
4343

44-
SQL provided by Db2 for i allows you to run CL commands in a script. Additionally there are `json`, `csv`, `sql` and `rpg` prefixes, which will open the result set in the chosen format.
44+
SQL provided by Db2 for i allows you to run CL commands in a script. Additionally there are `json`, `csv`, `sql`, `udtf`, and `rpg` prefixes, which will open the result set in the chosen format.
4545

4646
```sql
47-
-- result set as normal table
47+
-- Result set as normal table
4848
select * from sample.employee;
4949

50-
-- result set as JSON, will open in a new file
50+
-- Result set as JSON (will open in a new file)
5151
json: select * from sample.employee;
5252

53-
-- result set as CSV, will open in a new file
53+
-- Result set as CSV (will open in a new file)
5454
csv: select * from sample.employee;
5555

56-
-- result set as SQL insert statement
56+
-- Result set as SQL insert statements (will open in a new file)
5757
sql: select * from sample.employee;
5858

59-
-- RPG data structure based on result set columns
59+
-- User-defined table function based on result set columns (will open in a new file)
60+
udtf: select * from toystore.staff;
61+
62+
-- RPG data structure based on result set columns (will open in a new file)
6063
rpg: select * from sample.employee;
6164

62-
-- run CL commands. output is directed to IBM i output channel
65+
-- Run CL commands (output is directed to "Db2 for i: Results" view)
6366
cl: dspffd sample/employee
6467
```
6568

66-
### Updatable cells
69+
### Updatable Cells
6770

68-
It's possible to update directly from running a SQL statement. You can use the `update:` prefix with a select statement to make the result set updatable. This will allow you to edit the data in the result set and then save the changes back to the database.
71+
It's possible to update directly from running a SQL statement. You can use the `update:` prefix with a select statement to make the result set updatable. This will allow you to edit the data in the result set and then save the changes back to the database. Use `Shift+Enter` to set a field to `null`.
6972

7073
A fully qualified table name is required for the fields to be editable.
7174

7275
```sql
7376
update: select * from sample.employee;
7477
```
7578

76-
#### Using nulls
79+
<Aside type="tip">
80+
At the bottom of the **Results** view, you can observe the update statement that will be executed as you edit the data. It will only be executed once you press `Enter`.
81+
</Aside>
7782

78-
Enter the value `null` to set a column to *null*. If the column cannot accept at least 4 characters, then `-` (a dash) may be used.
83+
![](./images/updatePrefix.png)
7984

80-
### Binding parameters
85+
### Binding Parameters
8186

8287
It is possible to bind to SQL parameters inside of SQL statements - both `?` markers and named parameters (e.g. `:param1`) are supported - by using the `bind:` prefix. `bind:` is followed by a list of strings or numbers, either space or comma separated. When executing the prefix, it will find the most previous statement in the document to bind to.
8388

@@ -93,7 +98,13 @@ bind: '000010', 'A00';
9398
bind: '000020', 'A00';
9499
```
95100

96-
## Syntax checking
101+
## Statement History
102+
103+
When you execute an SQL statement, it will be prepended to your **Statement History** view. For any commonly used SQL statements, you can star them to make them easily readily accessible.
104+
105+
![](./images/statementHistory.png)
106+
107+
## Syntax Checking
97108

98109
When connected to an IBM i, the syntax checker has the following options:
99110

@@ -111,38 +122,54 @@ The syntax checker configuration is available through the VS Code settings (and
111122

112123
## SQL Job Manager
113124

114-
This view allows users to manage different SQL jobs, each with their own unique JDBC configuration. A new job can be created by clicking the database icon in the SQL Job Manage title bar. Or, if you have not created a new job before, there is a big button to do the same action.
125+
The **SQL Job Manager** view allows users to manage different SQL jobs, each with their own unique JDBC configuration. A new job can be created by clicking the database icon in the **SQL Job Manager** title bar. Or, if you have not created a new job before, there is a big button to do the same action.
115126

116127
![](./images/sqlJobManager-newJob.png)
117128

118129
Your active job will be marked with a highlighted icon. **The active job is used for all SQL statement execution**, including SQL that powers the Schema Browser, user-executed SQL statements, etc. You can change the active job by simply clicking the job you choose to use. You will see the highlighted icon change to indicate the active job.
119130

120-
### Editing job configuration
131+
### Editing Job Configuration
132+
133+
You can use the 'Edit Connection Properties' inline button (pencil icon) on any job to edit the JDBC properties. When the 'Apply Changes' button is pressed, any changes are saved and the job is restarted to fully apply the changes.
134+
135+
![](./images/jobConfiguration.png)
136+
137+
You are able to right-click on any job to save those job settings, allowing it to be easily reused. This is done using the 'Save settings to config' right-click action which will prompt you to enter a name for the configuration. Once saved, you will see a **Saved Configuration** folder appear, with all your saved configs. Clicking on a saved config will launch a new job with those pre-defined settings. You can use the pencil icon on any saved configuration to edit it. Lastly, a saved config can also be set as your default (which will be highlighted in yellow) so that any new jobs which are spun up will default to these job settings.
138+
139+
![](./images/savedConfigurations.png)
121140

122-
You can use the pencil icon on any job to edit the JDBC properties. When the Apply Changes button is pressed, any changes are saved and the job is restarted, to fully apply the changes.
141+
You also have the ability to set cross system default connection properties which serve as a fallback when no saved config is set as the default. For example, if you prefer to use `sql` rather than `system` naming across all system, this can be set here.
123142

124-
You are able to right-click on any job to save those job settings, allowing it to be easily reused. Using the 'Save settings to config' right-click action will prompt you to enter a name for the configuration. Once saved, you will see a 'Saved Configuration' folder appear, with all your saved configs. Clicking on a saved config will launch a new job with those pre-defined settings. You can use the pencil icon on any saved configuration to edit it.
143+
<Aside type="caution">
144+
These default connection properties are not connection specific meaning that they are not tied to any one specific Code for IBM i connection. These apply cross system so it is best to ensure that settings which are set are appropriate for all systems.
145+
</Aside>
125146

126-
## Using the Schema Browser
147+
## Schema Browser
127148

128-
The Db2 for i extension adds a view called Schema Browser which allows the user to add existing schemas to the list and will allow them to browse existing database objects. You can right-click on SQL objects to show more actions. Each SQL object type may have unique actions.
149+
The Db2 for i extension has view called **Schema Browser** which allows the user to add existing schemas to the list and will allow them to browse existing database objects.
129150

130151
<Aside type="note">
131152
The Schema Browser requires an active SQL Job to function.
132153
</Aside>
133154

134-
### Viewing table contents
155+
![](./images/manageSchemaBrowser.png)
156+
157+
Once you have your desired schemas added, you can browse your database objects based on type. You can use the 'Filter Database Object Types' option to filter which types are are shown. You can also right-click on SQL objects to see more actions (each SQL object type may have unique actions).
158+
159+
![](./images/schemaBrowser.png)
135160

136-
If you are using the Schema Browser to browse objects, you are able to use the 'View contents' icon when hovering over a table, view, or alias to cause a basic SQL select statement to be generated and executed.
161+
### Viewing Table Contents
137162

163+
If you are using the **Schema Browser** to browse objects, you are able to use the 'View contents' icon when hovering over a table, view, or alias to cause a basic SQL select statement to be generated and executed.
138164

139-
## Using Examples
140165

141-
The Examples view provides users with a set of SQL example scripts that can be used as a learning tool or as a starting point for their own SQL scripts. These examples are grouped into categories to make it easy to find what you are looking for. You can hover over any example to get a preview of the SQL script or click on it to open a copy which you can freely edit.
166+
## SQL Examples
167+
168+
The **Examples** view provides users with a set of SQL example scripts that can be used as a learning tool or as a starting point for their own SQL scripts. These examples are grouped into categories to make it easy to find what you are looking for. You can hover over any example to get a preview of the SQL script or click on it to open a copy which you can freely edit.
142169

143170
![](./images/examplesPreview.png)
144171

145-
On top of the built-in examples, users can also add specific directories containing their own SQL examples using the `Add...` button under the `Custom Examples Directories` submenu on the Examples view. All SQL files in the specified directories and at most one subdirectory level deeper will be picked up. By default, the folder name will be the category and the file name will be the name of the example. This can be customized by optionally including a comment in the file with the tags `category` and `description`.
172+
On top of the built-in examples, users can also add specific directories containing their own SQL examples using the `Add...` button under the `Custom Examples Directories` submenu on the **Examples** view. All SQL files in the specified directories and at most one subdirectory level deeper will be picked up. By default, the folder name will be the category and the file name will be the name of the example. This can be customized by optionally including a comment in the file with the tags `category` and `description`.
146173

147174
![](./images/examplesAdd.png)
148175

@@ -152,7 +179,7 @@ Once you have added a custom examples directory, you can quickly save new exampl
152179

153180
## SQL Error Logging Facility (SELF)
154181

155-
SQL Error Logging Facility (SELF) offers a comprehensive view that can help users understand specific SQL errors or warnings. The SELF view can be accessed through the IBM i panel next to the Results View.
182+
SQL Error Logging Facility (SELF) offers a comprehensive view that can help users understand specific SQL errors or warnings. The SELF view can be accessed through the IBM i panel next to the **Results** View.
156183

157184
Additional documentation of SELF can be found [here](https://www.ibm.com/docs/en/i/7.5?topic=tools-sql-error-logging-facility-self)
158185

@@ -200,7 +227,7 @@ Notebooks now supports Db2 for IBM i when using the database extension. If you h
200227
![](./images/notebook.png)
201228

202229
<Aside type="tip">
203-
We are expecting a full release of Notebooks in vscode-db2i 1.0.0.
230+
We are expecting a full release of Notebooks in vscode-db2i 1.0.0.
204231
</Aside>
205232

206233
### How to create a Notebook
@@ -211,7 +238,9 @@ There are a few ways to create an IBM i Notebook:
211238
2. You can find 'IBMi i: New Notebook' in the command palette.
212239
3. Open a `.inb` file (which stands for 'i Notebook')
213240

214-
**You can also find Notebook samples from the Examples view, under Notebooks.**
241+
<Aside type="tip">
242+
You can also find Notebook samples from the Examples view, under Notebooks.
243+
</Aside>
215244

216245
### The life of a Notebook
217246

@@ -300,6 +329,22 @@ limit 10
300329
</TabItem>
301330
</Tabs>
302331

332+
## Keyboard Shortcuts
333+
334+
The following keyboard shortcuts are set by the extension. This can be freely customized using the `Open Keyboard Shortcuts` command from the command palette.
335+
336+
| Command | Windows | MacOS |
337+
|----------------------------|----------------|---------------|
338+
| Run statement | `ctrl+r` | `cmd+r` |
339+
| Run statement in new view | `ctrl+alt+r` | `cmd+ctrl+r` |
340+
| Run all statements | `ctrl+shift+a` | `cmd+shift+a` |
341+
| Run statements from cursor | `ctrl+shift+r` | `cmd+shift+r` |
342+
| Run and explain statement | `ctrl+u` | `cmd+u` |
343+
| Explain without running | `ctrl+e` | `cmd+e` |
344+
| Open SQL Document | `ctrl+alt+n` | `cmd+alt+n` |
345+
| Execute cell | `ctrl+r` | `cmd+r` |
346+
347+
303348
## AI Integrations
304349

305350
<LinkCard title="Db2 for i Code Assistant" href="../../ai/db2i/code-assistant/" />

0 commit comments

Comments
 (0)