Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
davidastart committed Jan 16, 2024
2 parents ba183d0 + 00f9e61 commit 400519f
Show file tree
Hide file tree
Showing 845 changed files with 7,144 additions and 2,381 deletions.
28 changes: 7 additions & 21 deletions 23cfree/change-pw/change-pw-sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

## Introduction

Resetting the password for the hol23c user in the Oracle Database and starting up ORDS, which will be needed to start up other applications.
Resetting the password for the hol23c user in the Oracle Database.

Estimated Time: 5 minutes

### Objectives

In this lab, you will:
* Open SQL Plus
* Set the password for the hol23c user

### Prerequisites
Expand All @@ -17,7 +18,7 @@ This lab assumes you have:
* Oracle Database 23c Free Developer Release
* A terminal or console access to the database

## Task 1: Setting database user password and starting ORDS
## Task 1: Setting database user password

1. The first step is to get to a command prompt. If you need to open a terminal and you are running in a Sandbox environment click on Activities and then Terminal.

Expand All @@ -31,9 +32,6 @@ This lab assumes you have:
[FREE:oracle@hol23cfdr:~]$
```

<!-- ![Set environment](images/set-envt-free1.png " ") -->


3. Next connect to your database.
```
[FREE:oracle@hol23cfdr:~]$ <copy>sqlplus / as sysdba</copy>
Expand Down Expand Up @@ -64,18 +62,18 @@ This lab assumes you have:

5. To change the password for the user hol23c use the "alter user \[username\] identified by \[new password\]" command. The syntax below for the hol23c user, make sure to replace new\_password\_here to your new password. Throughout this workshop we will use the Welcome123 password.
```
<copy>alter user hol23c identified by </copy> [new_password_here];
alter user hol23c identified by [new_password_here];
```
```
SQL> alter user hol23c identified by Welcome123;
SQL> <copy>alter user hol23c identified by Welcome123;</copy>
User altered.
SQL>
```
![Change password](images/change-password1.png " ")

6. Once the password has been changed you can exit SQL Plus.
6. Once the password has been changed you can exit SQL Plus as sysdba.

```
SQL> <copy>exit</copy>
Expand All @@ -86,18 +84,6 @@ Version 23.2.0.0.0

![Exit](images/exit1.png " ")

7. To start ORDS, from the same command prompt use the following command. The output of [1] 204454 is just an example, your output could be different.

```
[FREE:oracle@hol23cfdr:~]$ <copy>ords serve > /dev/null 2>&1 &</copy>
[1] 204454
[FREE:oracle@hol23cfdr:~]$
```

>**NOTE:** You must leave this terminal open and the process running. Closing either will stop ORDS from running, and you will not be able to access other applications that are used in this lab.
![Start ORDS](images/ords1.png " ")

You may now **proceed to the next lab**.

## Learn More
Expand All @@ -107,4 +93,4 @@ You may now **proceed to the next lab**.
## Acknowledgements
* **Author** - Kaylien Phan, William Masdon
* **Contributors** - David Start
* **Last Updated By/Date** - Hope Fisher, Program Manager, June 2023
* **Last Updated By/Date** - Hope Fisher, Program Manager, Oct 2023
4 changes: 2 additions & 2 deletions 23cfree/introduction/intro-js-generic.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ In addition to PL/SQL and Java it is now possible to leverage the Smart DB parad

This workshop introduces JavaScript in Oracle Database 23c on Linux x86-64 and walks you through all the steps necessary to be productive with the new language. It complements [Oracle Database JavaScript Developer's Guide](https://docs.oracle.com/en/database/oracle/oracle-database/23/mlejs/index.html). You will use both command-line tools as well as a graphical user interface when creating code.

> **Note:** There is a strong focus on command line tools for a reason: many software projects rely on automation (keywords Continuous Integration/Continuous Delivery). Graphical user interfaces don't work in this workflow, however anything you can control on the command line does. This workshop aims at preparing you for working with Continuous Integration (CI) pipelines as much as possible. Note though that a wealth of IDEs exists for writing JavaScript code. Database Actions has strong support for JavaScript in Oracle Database 23c Free-Developer Release and you will see it used a lot.
> **Note:** There is a strong focus on command line tools for a reason: many software projects rely on automation (keywords Continuous Integration/Continuous Delivery). Graphical user interfaces don't work in this workflow, however anything you can control on the command line does. This workshop aims at preparing you for working with Continuous Integration (CI) pipelines as much as possible. Note though that a wealth of Integrated Development Environments (IDEs) exists for writing JavaScript code. Database Actions has strong support for JavaScript in Oracle Database 23c Free Release and you will see it used a lot.
Estimated Workshop Time: 1 hours 30 minutes

Expand All @@ -34,4 +34,4 @@ You may now proceed to the next lab.

- **Author** - Martin Bach, Senior Principal Product Manager, ST & Database Development
- **Contributors** - Lucas Braun, Sarah Hirschfeld
- **Last Updated By/Date** - Martin Bach 09-MAY-2023
- **Last Updated By/Date** - Martin Bach 17-NOV-2023
101 changes: 55 additions & 46 deletions 23cfree/js-generic-functions/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ After creating JavaScript modules and environments in the previous lab you will

Estimated Lab Time: 10 minutes

[](videohub:1_ffqhyknx)

### Objectives

In this lab, you will:
Expand All @@ -21,7 +19,7 @@ In this lab, you will:

This lab assumes you have:

- An Oracle Database 23c Free - Developer Release environment available to use
- An Oracle Database 23c Free environment available to use
- Created the `emily` account as per Lab 1
- Completed Lab 2 where you created a number of JavaScript modules in the database

Expand Down Expand Up @@ -84,51 +82,56 @@ In this task you will learn how to create a call specification based on the MLE

```
LINE TEXT
----- -----------------------------------------------------------------------------------
1 function string2obj(inputString) {
2 if ( inputString === undefined ) {
3 throw `must provide a string in the form of key1=value1;...;keyN=valueN`;
4 }
5 let myObject = {};
6 if ( inputString.length === 0 ) {
7 return myObject;
8 }
9 const kvPairs = inputString.split(";");
10 kvPairs.forEach( pair => {
11 const tuple = pair.split("=");
12 if ( tuple.length === 1 ) {
13 tuple[1] = false;
14 } else if ( tuple.length != 2 ) {
15 throw "parse error: you need to use exactly one '=' between " +
16 "key and value and not use '=' in either key or value";
17 }
18 myObject[tuple[0]] = tuple[1];
19 });
20 return myObject;
21 }
22 /**
23 * convert a JavaScript object to a string
24 * @param {object} inputObject - the object to transform to a string
25 * @returns {string}
26 */
27 function obj2String(inputObject) {
28 if ( typeof inputObject != 'object' ) {
29 throw "inputObject isn't an object";
30 }
31 return JSON.stringify(inputObject);
32 }
33 export { string2obj, obj2String }
----- ------------------------------------------------------------------------------------------
1 /**
2 * convert a delimited string into key-value pairs and return JSON
3 * @param {string} inputString - the input string to be converted
4 * @returns {JSON}
5 */
6 function string2obj(inputString) {
7 if ( inputString === undefined ) {
8 throw `must provide a string in the form of key1=value1;...;keyN=valueN`;
9 }
10 let myObject = {};
11 if ( inputString.length === 0 ) {
12 return myObject;
13 }
14 const kvPairs = inputString.split(";");
15 kvPairs.forEach( pair => {
16 const tuple = pair.split("=");
17 if ( tuple.length === 1 ) {
18 tuple[1] = false;
19 } else if ( tuple.length != 2 ) {
20 throw "parse error: you need to use exactly one '=' between " +
21 "key and value and not use '=' in either key or value";
22 }
23 myObject[tuple[0]] = tuple[1];
24 });
25 return myObject;
26 }
27 /**
28 * convert a JavaScript object to a string
29 * @param {object} inputObject - the object to transform to a string
30 * @returns {string}
31 */
32 function obj2String(inputObject) {
33 if ( typeof inputObject != 'object' ) {
34 throw "inputObject isn't an object";
35 }
36 return JSON.stringify(inputObject);
37 }
38 export { string2obj, obj2String }
```

You can see in line 33 that both functions declared in the module are exported.
You can see in line 38 that both functions declared in the module are exported.

If you prefer a graphical user interface log into Database Actions and navigate to MLE JS from the Launchpad. Right-click on `HELPER_MODULE_INLINE` and select Edit from the context menu. This brings up the source code for the module:

![Source code for HELPER_MODULE_INLINE in Database Actions](images/sdw-source-code.jpg)

2. Create call specification for `helper_module_inline`

You can see from the output above that both functions in the module are exported (line 35). This allows us to create call specifications. Before you go ahead and create one you need to decide whether you need a PL/SQL function or procedure. In the above case both JavaScript functions return data:
You can see from the output above that both functions in the module are exported (line 38). This allows us to create call specifications. Before you go ahead and create one you need to decide whether you need a PL/SQL function or procedure. In the above case both JavaScript functions return data:

- `string2obj(string)` returns a JavaScript object
- `object2String(object)` returns a string
Expand Down Expand Up @@ -220,9 +223,13 @@ Creating call specifications for functions exported by the `business_logic` modu
```sql
create mle module business_logic language javascript as
import { string2obj } from 'helpers';
/**
* A simple function accepting a set of key-value pairs, translates it to JSON bef
* inserting the order in the database.
* @param {string} orderData a semi-colon separated string containing the order de
* @returns {boolean} true if the order could be processed successfully, false oth
*/
export function processOrder(orderData) {
const orderDataJSON = string2obj(orderData);
const result = session.execute("...");
Expand Down Expand Up @@ -255,9 +262,10 @@ Before you can create a call specification for `processOrder()` you must ensure
You should see the following output:
```
ENV_NAME IMPORT_NAME MODULE_NAME
-------------------- ------------------------------ ------------------------------
BUSINESS_MODULE_ENV helpers HELPER_MODULE_INLINE
ENV_NAME IMPORT_NAME MODULE_NAME
------------------------------ ------------------------------ ------------------------------
BUSINESS_MODULE_ENV BUSINESS_LOGIC BUSINESS_LOGIC
BUSINESS_MODULE_ENV helpers HELPER_MODULE_INLINE
```
2. Create the call specification
Expand Down Expand Up @@ -454,7 +462,7 @@ In scenarios where you don't need the full flexibility of JavaScript modules and

## Task 6: View dictionary information about call specifications

The data dictionary has been enhanced in Oracle Database 23c Free-Developer Release to provide information about call specifications. A new view, named `USER_MLE_PROCEDURES` provides the mapping between PL/SQL code units and JavaScript. There are of course corresponding _ALL/DBA/CDB_ views as well.
The data dictionary has been enhanced in Oracle Database 23c Free to provide information about call specifications. A new view, named `USER_MLE_PROCEDURES` provides the mapping between PL/SQL code units and JavaScript. There are of course corresponding _ALL/DBA/CDB_ views as well.

1. Query `USER_MLE_PROCEDURES` to learn more about the existing call specifications

Expand Down Expand Up @@ -490,6 +498,7 @@ The data dictionary has been enhanced in Oracle Database 23c Free-Developer Rele
HELPER_PKG STRING2OBJ HELPER_MODULE_INLINE
ISEMAIL VALIDATOR
STRING2OBJ
STRING_TO_JSON HELPER_MODULE_BFILE
```

Due to the way the view is defined, you will sometimes see both `object_name` and `procedure_name` populated, while sometimes just `object_name` is populated and `procedure_name` is null.
Expand All @@ -510,4 +519,4 @@ You many now proceed to the next lab.

- **Author** - Martin Bach, Senior Principal Product Manager, ST & Database Development
- **Contributors** - Lucas Braun, Sarah Hirschfeld
- **Last Updated By/Date** - Martin Bach 09-MAY-2023
- **Last Updated By/Date** - Martin Bach 28-NOV-2023
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 23cfree/js-generic-functions/images/sdw-simple-call-spec.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified 23cfree/js-generic-functions/images/sdw-source-code.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 7 additions & 9 deletions 23cfree/js-generic-get-started-example/get-started-example.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ Before jumping into the description of JavaScript features and all their details
Estimated Time: 10 minutes

[](videohub:1_d307bfag)

### Objectives

In this lab, you will:
Expand All @@ -24,8 +22,8 @@ In this lab, you will:

This lab assumes you have:

- Oracle Database 23c Free - Developer Release
- You have a working noVNC environment or comparable setup
- Access to an Oracle Database 23c Free instance
- Sufficient privileges to create a database user

## Task 1: Create a schema to store the JavaScript module

Expand Down Expand Up @@ -79,7 +77,7 @@ All the steps in this lab can either be completed in `sqlplus` or `sqlcl`. The i

In this step you prepare the creation of the developer account. The instructions in the following snippet create a new account, named `emily`. It will be used to store JavaScript modules in the database.

Save the snippet in a file, for example `${HOME}/setup.sql` and execute it in `sqlcl` or `sqlplus`. You can use graphical text editors installed on the system via the Activities button or the command line.
Save the snippet in a file, for example `${HOME}/hol23c/setup.sql` and execute it in `sqlcl` or `sqlplus`. You can use graphical text editors installed on the system via the Activities button or the command line.

```sql
<copy>set echo on
Expand All @@ -104,7 +102,7 @@ All the steps in this lab can either be completed in `sqlplus` or `sqlcl`. The i
You should still be connected to `freebdb1` as `SYS` as per the previous step. If not, connect to `freepdb1` as `SYS` before executing the following command:

```sql
<copy>start ${HOME}/setup.sql</copy>
<copy>start ${HOME}/hol23c/setup.sql</copy>
```

Here is some sample output of an execution:
Expand Down Expand Up @@ -201,7 +199,7 @@ curl -Lo /home/oracle/hol23c/validator.min.js 'https://objectstorage.us-ashburn-
## Task 3: Create the JavaScript module in the database
JavaScript in Oracle Database 23c Free - Developer Release allows you to load JavaScript modules using the `BFILE` clause, specifying a directory object and file name. You prepared for the `create mle module` command in the previous step, now it's time to execute it:
JavaScript in Oracle Database 23c Free allows you to load JavaScript modules using the `BFILE` clause, specifying a directory object and file name. You prepared for the `create mle module` command in the previous step, now it's time to execute it:

1. Connect to the database as the `emily` user:

Expand Down Expand Up @@ -244,7 +242,7 @@ JavaScript in Oracle Database 23c Free - Developer Release allows you to load Ja
VALIDATOR JAVASCRIPT
```

You can read more about creating JavaScript modules in Oracle Database 23c Free - Developer release in chapter 2 of the JavaScript Developer's Guide.
You can read more about creating JavaScript modules in Oracle Database 23c Free in chapter 2 of the JavaScript Developer's Guide.
## Task 4: Expose the module's functionality to PL/SQL and SQL

Expand Down Expand Up @@ -313,4 +311,4 @@ You many now proceed to the next lab.

- **Author** - Martin Bach, Senior Principal Product Manager, ST & Database Development
- **Contributors** - Lucas Braun, Sarah Hirschfeld
- **Last Updated By/Date** - Martin Bach 09-MAY-2023
- **Last Updated By/Date** - Martin Bach 17-NOV-2023
Loading

0 comments on commit 400519f

Please sign in to comment.