项目作者: nethoncho

项目描述 :
An example sails application using oracle stored procedures
高级语言: PLSQL
项目地址: git://github.com/nethoncho/sails-oracledb-sp-example.git
创建时间: 2015-08-15T05:14:02Z
项目社区:https://github.com/nethoncho/sails-oracledb-sp-example

开源协议:MIT License

下载


sails-oracledb-sp-example

About

Example sails project using the sails-oracledb-sp adapter

The current version exposes the Oracle HR Employee table via a REST API and websockets.
It includes an Angular UI.

Installation

The setup procedure relies on Oracle’s VM.

install VirtualBox
Download and install Oracle VM VirtualBox on your host system

Download the Oracle 12c VM

The Oracle 12c VM is provided in an Open Virtual Appliance (OVA) file. An OVA is essentially an archive that includes a disk image and other supporting files that are suitable to be imported into VirtualBox as a VM. The VM provided by this OVA includes Oracle Linux 7 and Oracle Database 12c Release 1 Enterprise Edition.

Download the Oracle 12c OVA, which is the Oracle DB Developer VM. Launch it by double clicking it and then import it into VirtualBox.

After the VM is launched then it needs a bit of configuration.

Enable the Oracle 12c’s VM’s bidirectional clipboard.

In the VM’s menu: Devices->shared clipboard->bidirectional.

Set the VM’s memory for 3GB. Set the VM’s memory for 3GB.

In the VM’s menu: Machine->settings->system and configure for 3GB of memory.

Database Information:

  • Oracle SID : cdb1
  • Pluggable DB : orcl
  • ALL PASSWORDS ARE : oracle
  • The Linux Username and password is oracle.

Install Node

  1. $sudo su -
  2. # cd Downloads
  3. # wget https://nodejs.org/dist/v0.12.7/node-v0.12.7-linux-x64.tar.gz
  4. # tar xzf node-v0.12.7-linux-x64.tar.gz
  5. # cd node-v0.12.7-linux-x64

Node.js is installed in /usr/local directory. The following command copies the files to the correct sub-directotories in /usr/local:

  1. #for dir in bin include lib share; do cp -par ${dir}/* /usr/local/${dir}/; done

To verify version of node and npm, type:

  1. #node --version
  2. v0.12.7
  3. #npm --version
  4. 3.3.8

Now install npm

  1. #npm install -g npm

Install the Oracle Instant Client ‘Basic’ and ‘SDK’ RPMs

The Oracle VM comes with FireFox preinstalled.

Download both the Oracle Instant Client ‘Basic’ and Oracle Instant Client ‘SDK’ RPMs

Download Oracle Instant Client ‘Basic’ and Oracle Instant Client ‘SDK’ RPMs

After the download has completed then copy the downloaded rpms to /home/oracle/rpms and then install the packages as root

  1. $mkdir /home/oracle/rpms
  2. $mv /home/oracle/Downloads/*.rpm /home/oracle/rpms
  3. $sudo su -
  4. #cd /home/oracle/rpms
  5. #rpm -ivh oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm
  6. #rpm -ivh oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
  7. #exit

Add the following lines to /home/oracle/.bashrc:

  1. export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
  2. export PATH=/opt/node-v4.1.0-linux-x64/bin:$PATH

Install git

  1. sudo su -
  2. #yum install git
  3. exit

Installation

  1. $ git clone https://github.com/nethoncho/sails-oracledb-sp-example.git
  2. $ cd sails-oracledb-sp-example
  3. $ npm install
  4. $ bower install

Configuration

Edit the oraclehr adapter in the config/connections.js file to match your needs

  1. module.exports.connections = {
  2. oraclehr: {
  3. adapter: 'oracle-sp',
  4. user: 'scott',
  5. password: 'tiger',
  6. package: 'HR',
  7. cursorName: 'DETAILS',
  8. connectString: 'localhost/orcl'
  9. }
  10. };

Apply the stored procedures to the HR schema in db/

  1. $ cd db

The order is important

  1. sqlplus "scott/tiger@localhost/orcl" < create_pkg_hr-child.pls
  2. sqlplus "scott/tiger@localhost/orcl" < create_pkgbdy_hr-child.plb
  3. sqlplus "scott/tiger@localhost/orcl" < create_pkg_hr.pls
  4. sqlplus "scott/tiger@localhost/orcl" < create_pkgbdy_hr.plb
  5. sqlplus "scott/tiger@localhost/orcl" < create_type_retcodes.sql
  1. $ cd ..

Run the application

launch Sails:

  1. $ cd ~/sails-oracledb-sp-example
  2. $ sails lift

Point your browser to http://localhost:1337/#/employees to start UI

License

MIT
© 2015