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: extension-api/README.md
+55-8Lines changed: 55 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,18 @@
1
-
[TOC]
1
+
# Table of Contents <!-- omit in toc -->
2
+
3
+
-[Introduction](#introduction)
4
+
-[Getting Started](#getting-started)
5
+
-[Prerequisites](#prerequisites)
6
+
- [Install `Oracle SQL Developer Extension for VSCode`](#install--oracle-sql-developer-extension-for-vscode-)
7
+
- [Install Typescript:](#install-typescript-)
8
+
- [Install Type definitions for VSCode](#install-type-definitions-for-vscode)
9
+
-[Installation](#installation)
10
+
-[Usage](#usage)
11
+
-[Connections](#connections)
12
+
-[Worksheets](#worksheets)
13
+
-[Contributing](#contributing)
14
+
-[Security](#security)
15
+
-[License](#license)
2
16
3
17
# Introduction
4
18
@@ -14,45 +28,52 @@ Provides Typescript type definitions for the API exposed by [Oracle SQL Develope
14
28
15
29
If you haven't already, install `Oracle SQL Developer Extension for VSCode` using the following [link](https://marketplace.visualstudio.com/items?itemName=Oracle.sql-developer).
16
30
17
-
**Note:** The extension supports VSCode >=1.97.0, so make sure your VSCode version is at least 1.97.
31
+
**Note:** The extension supports VSCode >=1.101.0, so make sure your VSCode version is at least 1.101.0.
18
32
19
33
### Install Typescript:
20
34
21
35
NPM
36
+
22
37
```sh
23
38
npm install --save-dev typescript
24
39
```
25
40
26
41
YARN
42
+
27
43
```sh
28
44
yarn add --dev typescript
29
45
```
30
46
31
47
### Install Type definitions for VSCode
32
48
33
49
NPM
50
+
34
51
```sh
35
52
npm install --save-dev @types/vscode
36
53
```
37
54
38
55
YARN
56
+
39
57
```sh
40
58
yarn add --dev @types/vscode
41
59
```
42
60
43
61
## Installation
44
62
45
63
NPM
64
+
46
65
```sh
47
66
npm install --save-dev @oracle/sql-developer-api
48
67
```
49
68
50
69
YARN
70
+
51
71
```sh
52
72
yarn add --dev @oracle/sql-developer-api
53
73
```
54
74
55
75
# Usage
76
+
56
77
The following code sample illustrates how to retrieve an API instance and use it:
57
78
58
79
```ts
@@ -65,15 +86,16 @@ if (!extension) {
65
86
const api =extension.exports;
66
87
```
67
88
68
-
69
89
## Connections
70
90
71
91
The API exposes a `Connections` interface, allowing access to connections and connection sessions. For instance, the following snippet allows retrieving the first connection in the connections list, connecting to it and executing a script against the session:
92
+
72
93
```ts
73
94
const connections =api.connections().list();
74
95
const session =awaitconnections[0].connect();
75
96
const resultSet =awaitsession.executeQuery({ sql: 'SELECT * FROM dual;' });
76
97
```
98
+
77
99
The following table lists all available connection and connection session methods:
78
100
79
101
<table>
@@ -109,25 +131,31 @@ The following table lists all available connection and connection session method
109
131
</tr>
110
132
111
133
<tr>
112
-
<td rowspan="2">Connection Session</td>
134
+
<td rowspan="3">Connection Session</td>
113
135
<td>executeQuery</td>
114
136
<td>Executes a DQL query and returns a ResultSet object.</td>
115
137
</tr>
116
138
<tr>
117
139
<td>execute</td>
118
140
<td>Executes the given SQL script and returns a result in the specified format.</td>
119
141
</tr>
142
+
<tr>
143
+
<td>prepareSql</td>
144
+
<td>Prepares the SQL to execute by analyzing the given sql script and extracts binds and substitutions.</td>
145
+
</tr>
120
146
121
147
</table>
122
148
123
149
## Worksheets
124
150
125
151
The API also exposes a `Worksheets` interface, that provides access to SQL worksheets. The following snippets illustrates how this interface can be leveraged to retrieve the content of the active worksheet and executes it against the attached session:
The following table lists all available worksheets methods:
132
160
133
161
<table>
@@ -172,19 +200,38 @@ The following table lists all available worksheets methods:
172
200
<td>Registers a command that can be executed from within a worksheet e.g. from the toolbar.</td>
173
201
</tr>
174
202
203
+
<tr>
204
+
<td rowspan="3">Worksheet</td>
205
+
<td>editor</td>
206
+
<td>The VSCode text editor that's backing the worksheet.</td>
207
+
</tr>
208
+
<tr>
209
+
<td>session</td>
210
+
<td>The session associated with the worksheet.</td>
211
+
</tr>
212
+
<tr>
213
+
<td>attach</td>
214
+
<td>Allows attaching the worksheet to a connection session.</td>
215
+
</tr>
175
216
176
217
</table>
177
218
178
219
Consult [the code samples](https://github.com/oracle/sql-developer-vscode/tree/main/samples) for more examples and code snippets on how to use different parts of the API.
179
220
180
-
<!-- # Changelog: skipped for first release, will be used starting from next release -->
221
+
# Changelog
222
+
223
+
Refer to the [changelog](./CHANGELOG.md) for full release notes and version history.
0 commit comments