You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/extensions/db2i/index.mdx
+76-31Lines changed: 76 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ The extension can be [installed from the Marketplace](https://marketplace.visual
20
20
21
21
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)<Iconname="github"class="icon-inline" />.
22
22
23
-
## Executing statements
23
+
## Executing Statements
24
24
25
25
Either:
26
26
@@ -35,49 +35,54 @@ After you have an SQL file open, you can either:
35
35
* use the play button in the top right to execute
36
36
* use the shortcut (control / command + R) to execute the statement
37
37
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.
39
39
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.
41
41
42
-
### SQL prefixes
42
+
### SQL Prefixes
43
43
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.
45
45
46
46
```sql
47
-
--result set as normal table
47
+
--Result set as normal table
48
48
select*fromsample.employee;
49
49
50
-
--result set as JSON, will open in a new file
50
+
--Result set as JSON (will open in a new file)
51
51
json: select*fromsample.employee;
52
52
53
-
--result set as CSV, will open in a new file
53
+
--Result set as CSV (will open in a new file)
54
54
csv: select*fromsample.employee;
55
55
56
-
--result set as SQL insert statement
56
+
--Result set as SQL insert statements (will open in a new file)
57
57
sql: select*fromsample.employee;
58
58
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*fromtoystore.staff;
61
+
62
+
-- RPG data structure based on result set columns (will open in a new file)
60
63
rpg: select*fromsample.employee;
61
64
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)
63
66
cl: dspffd sample/employee
64
67
```
65
68
66
-
### Updatable cells
69
+
### Updatable Cells
67
70
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`.
69
72
70
73
A fully qualified table name is required for the fields to be editable.
71
74
72
75
```sql
73
76
update: select*fromsample.employee;
74
77
```
75
78
76
-
#### Using nulls
79
+
<Asidetype="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>
77
82
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
+

79
84
80
-
### Binding parameters
85
+
### Binding Parameters
81
86
82
87
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.
83
88
@@ -93,7 +98,13 @@ bind: '000010', 'A00';
93
98
bind: '000020', 'A00';
94
99
```
95
100
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
+

106
+
107
+
## Syntax Checking
97
108
98
109
When connected to an IBM i, the syntax checker has the following options:
99
110
@@ -111,38 +122,54 @@ The syntax checker configuration is available through the VS Code settings (and
111
122
112
123
## SQL Job Manager
113
124
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.
115
126
116
127

117
128
118
129
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.
119
130
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
+

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
+

121
140
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.
123
142
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
+
<Asidetype="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>
125
146
126
-
## Using the Schema Browser
147
+
## Schema Browser
127
148
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.
129
150
130
151
<Asidetype="note">
131
152
The Schema Browser requires an active SQL Job to function.
132
153
</Aside>
133
154
134
-
### Viewing table contents
155
+

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
+

135
160
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
137
162
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.
138
164
139
-
## Using Examples
140
165
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.
142
169
143
170

144
171
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`.
146
173
147
174

148
175
@@ -152,7 +179,7 @@ Once you have added a custom examples directory, you can quickly save new exampl
152
179
153
180
## SQL Error Logging Facility (SELF)
154
181
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.
156
183
157
184
Additional documentation of SELF can be found [here](https://www.ibm.com/docs/en/i/7.5?topic=tools-sql-error-logging-facility-self)
158
185
@@ -200,7 +227,7 @@ Notebooks now supports Db2 for IBM i when using the database extension. If you h
200
227

201
228
202
229
<Asidetype="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.
204
231
</Aside>
205
232
206
233
### How to create a Notebook
@@ -211,7 +238,9 @@ There are a few ways to create an IBM i Notebook:
211
238
2. You can find 'IBMi i: New Notebook' in the command palette.
212
239
3. Open a `.inb` file (which stands for 'i Notebook')
213
240
214
-
**You can also find Notebook samples from the Examples view, under Notebooks.**
241
+
<Asidetype="tip">
242
+
You can also find Notebook samples from the Examples view, under Notebooks.
243
+
</Aside>
215
244
216
245
### The life of a Notebook
217
246
@@ -300,6 +329,22 @@ limit 10
300
329
</TabItem>
301
330
</Tabs>
302
331
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.
0 commit comments