MacLochlainns Weblog

Michael McLaughlin's Technical Blog

Site Admin

Archive for the ‘Oracle’ Category

Mac SQL Developer Install

without comments

This how you install SQL Developer on Mac OS Yosemite. The first thing you need to do is download and install Java 8, not Java 7 on your Mac OS Yosemite as suggested on some web sites. You can determine whether or not Java is installed by running the following command:

Mac-Pro-3:~ username$ java -version
No Java runtime present, requesting install.

You must accept the Java license to install Java 8 on the Mac OS X operating system:

YosemiteInstallJava_01

You have the option of installing the Java SDK or JDK. I’ve opted to install Netbeans 8 with JDK 8u45, as you can tell from the screen capture after you launched the file:

YosemiteInstallJava_02

It is a standard Mac OS installation, which is why I didn’t bother showing any dialog messages. After installing the Java JDK or SDK, you should download SQL Developer 4.1 from Oracle’s web site. Below is a screen shot of the Oracle download web page where I’ve accepted the license agreement:

SQLDeveloperDownload

If you attempt to launch the installation and you’ve set your Mac Security to the “Mac App Store and identified developers” setting, you should raise the following exception:

SQLDeveloperInstall_01

If you reset the Mac Security to an “Anywhere” setting, you can install Oracle SQL Developer on Yosemite. Just make sure you reset it to the “Mac App Store and identified developers” setting after you install SQL Developer.

If you launch SQL Developer with the Security “Anywhere” setting, it displays the following dialog:

SQLDeveloperInstall_02

After you launch the program, you will see the following progress dialog:

SQLDeveloperInstall_03

The last step of the installation launches SQL Developer, as shown below:

SQLDeveloperInstall_04

Click the Connections icon to create an initial connection, like the following:

SQLDeveloperInstall_05

After connecting to the database, you can write and execute a query as shown in the next screen capture:

SQLDeveloperInstall_06

As always, I hope that this helps those who require an example to install SQL Server on a Mac OS.

Written by maclochlainn

June 12th, 2015 at 3:08 am

Bash Arrays & Oracle

with 2 comments

Last week, I wrote about how to use bash arrays and the MySQL database to create unit and integration test scripts. While the MySQL example was nice for some users, there were some others who wanted me to show how to write bash shell scripts for Oracle unit and integration testing. That’s what this blog post does.

If you don’t know much about bash shell, you should start with the prior post to learn about bash arrays, if-statements, and for-loops. In this blog post I only cover how to implement a bash shell script that runs SQL scripts in silent mode and then queries the database in silent mode and writes the output to an external file.

I’ve copied the basic ERD for the example because of a request from a reader. In their opinion it makes cross referencing the two posts unnecessary.

LittleERDModel

To run the bash shell script, you’ll need the following SQL files, which you can see by clicking not he title below. There are several differences. For example, Oracle doesn’t support a DROP IF EXISTS syntax and requires you to write anonymous blocks in their PL/SQL language; and you must explicitly issue a QUIT; statement even when running in silent mode unlike MySQL, which implicitly issues an exit.

If you don’t have a sample test schema to use to test this script, you can create a sample schema with the following create_user.sql file. The file depends on the existence of a users and temp tablespace.

Click the link below to see the source code for a script that let’s you create a sample user account as the system user:

The following list_oracle.sh shell script expects to receive the username, password, and fully qualified path in that specific order. The script names are entered manually in the array because this should be a unit test script.

This is an insecure version of the list_oracle.sh script because you provide the password on the command line. It’s better to provide the password as you run the script.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/bash
 
# Assign user and password
username="${1}"
password="${2}"
directory="${3}"
 
echo "User name:" ${username}
echo "Password: " ${password}
echo "Directory:" ${directory}
 
# Define an array.
declare -a cmd
 
# Assign elements to an array.
cmd[0]="actor.sql"
cmd[1]="film.sql"
cmd[2]="movie.sql"
 
# Call the array elements.
for i in ${cmd[*]}; do
  sqlplus -s ${username}/${password} @${directory}/${i} > /dev/null
done
 
# Connect and pipe the query result minus errors and warnings to the while loop.
sqlplus -s ${username}/${password} @${directory}/tables.sql 2>/dev/null |
 
# Read through the piped result until it's empty.
while IFS='\n' read actor_name; do
  echo $actor_name
done
 
# Connect and pipe the query result minus errors and warnings to the while loop.
sqlplus -s ${username}/${password} @${directory}/result.sql 2>/dev/null |
 
# Read through the piped result until it's empty.
while IFS='\n' read actor_name; do
  echo $actor_name
done

The IFS (Internal Field Separator) works with whitespace by default. The IFS on lines 29 and 37 sets the IFS to a line return ('\n'). That’s the trick to display the data, and you can read more about the IFS in this question and answer post.

You can run the shell script with the following syntax:

./list_oracle.sh sample sample /home/student/Code/bash/oracle > output.txt

You can then display the results from the output.txt file with the following command:

cat output.txt command:

It will display the following output:

User name: sample
Password:  sample
Directory: /home/student/Code/bash/oracle
 
Table Name
------------------------------
MOVIE
FILM
ACTOR
 
Actors in Films
----------------------------------------
Chris Hemsworth, Thor
Chris Hemsworth, Thor: The Dark World
Chris Pine, Star Trek
Chris Pine, Star Trek into Darkness
Chris Pratt, Guardians of the Galaxy

As always, I hope this helps those looking for a solution.

Written by maclochlainn

May 21st, 2015 at 1:16 am

Leaf node queries

without comments

A reader posted A dynamic level limiting hierarchical query about Oracle’s hierarchical queries. They wanted to know how to capture only the hierarchy above the level where the first leaf node occurs. They gave me the following hierarchy map as an example:

               1                                    2
        +-------------+                       +-----------+
        |             |                       |           |      
        3             5                       4           6
    +---------+    +-----------+           +-----+    +------+
    |         |    |           |           |     |    |      |
    7         9    11          13          8     10   12     14
+-----+   +-----+  +--+    +-------+                       +-----+ 
|     |   |     |     |    |       |                       |     |
15    17  19    21    23   27      29                     16     18
                                                                 +---+
                                                                     |
                                                                     20

You can find the node values and hierarchical level with the following query:

SELECT   tt.child_id
,        LEVEL
FROM     test_temp tt
WHERE    CONNECT_BY_ISLEAF  = 1
START
WITH     tt.parent_id IS NULL 
CONNECT
BY PRIOR tt.child_id = tt.parent_id
ORDER BY 2;

We really don’t need the node values to solve the problem. We only need the lowest LEVEL value returned by the query, which is 3. The combination of the MIN and CONNECT_BY_ISLEAF functions let us solve this problem without writing a PL/SQL solution. The subquery returns the lowest level value, which is the first level where a leaf node occurs.

SELECT   LPAD(' ', 2*(LEVEL - 1)) || tt.child_id AS child_id
FROM     test_temp tt
WHERE    LEVEL <= (SELECT   MIN(LEVEL)
                   FROM     test_temp tt
                   WHERE    CONNECT_BY_ISLEAF  = 1
                   START
                   WITH     tt.parent_id IS NULL 
                   CONNECT
                   BY PRIOR tt.child_id = tt.parent_id)
START
WITH     tt.parent_id IS NULL
CONNECT
BY PRIOR tt.child_id = tt.parent_id;

It returns:

               1                                    2
        +-------------+                       +-----------+
        |             |                       |           |      
        3             5                       4           6
    +---------+    +-----------+           +-----+    +------+
    |         |    |           |           |     |    |      |
    7         9    11          13          8     10   12     14

While I answered the question in a comment originally, it seemed an important trick that should be shared in its own post.

Written by maclochlainn

April 30th, 2015 at 4:31 pm

SQL Developer – Fedora

with 3 comments

This is the continuation of my efforts to stage an awesome Fedora developer’s instance. It shows you how to install Java 1.8 software development kit, which is nice to have. Though you can’t use Java 1.8 officially with Oracle SQL Developer 4.0.3 it is required for Oracle SQL Developer 4.1. Fortunately, the Oracle Product Manager, Jeff Smith has advised us that you can use Java 1.8 JDK with Oracle SQL Developer 4.0.3, and he’s written a comment to the blog post that it runs better with the Java 1.8 SDK.

After you install Oracle SQL Developer 4.0.3 or Oracle SQL Developer 4.1, you can watch Jeff Smith’s YouTube Video on SQL Developer 3.1 to learn how to use the basics of SQL Developer. I couldn’t find an updated version of the video for SQL Developer 4 but I didn’t try too hard.

You use yum as the root user to install Java SDK 1.8, much like my earlier Installing the Java SDK 1.7 and Java-MySQL Sample Program. The following command installs Java 8:

yum install -y java-1.8*

It produces the following output:

Loaded plugins: langpacks, refresh-packagekit
fedora/20/x86_64/metalink                                   |  18 kB  00:00     
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
pgdg93                                                      | 3.6 kB  00:00     
updates/20/x86_64/metalink                                  |  16 kB  00:00     
updates                                                     | 4.9 kB  00:00     
(1/2): mysql-tools-community/20/x86_64/primary_db           |  21 kB  00:00     
(2/2): updates/20/x86_64/primary_db                         |  13 MB  00:09     
updates/20/x86_64/pkgtags
updates
(1/2): updates/20/x86_64/pkgtags                            | 1.4 MB  00:02     
(2/2): updates/20/x86_64/updateinfo                         | 1.9 MB  00:04     
Package 1:java-1.8.0-openjdk-headless-1.8.0.31-1.b13.fc20.x86_64 already installed and latest version
Package 1:java-1.8.0-openjdk-javadoc-1.8.0.31-1.b13.fc20.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.31-1.b13.fc20 will be installed
---> Package java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.31-1.b13.fc20 will be installed
---> Package java-1.8.0-openjdk-demo.x86_64 1:1.8.0.31-1.b13.fc20 will be installed
---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.31-1.b13.fc20 will be installed
---> Package java-1.8.0-openjdk-src.x86_64 1:1.8.0.31-1.b13.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                          Arch   Version                  Repository
                                                                           Size
================================================================================
Installing:
 java-1.8.0-openjdk               x86_64 1:1.8.0.31-1.b13.fc20    updates 201 k
 java-1.8.0-openjdk-accessibility x86_64 1:1.8.0.31-1.b13.fc20    updates  12 k
 java-1.8.0-openjdk-demo          x86_64 1:1.8.0.31-1.b13.fc20    updates 1.9 M
 java-1.8.0-openjdk-devel         x86_64 1:1.8.0.31-1.b13.fc20    updates 9.2 M
 java-1.8.0-openjdk-src           x86_64 1:1.8.0.31-1.b13.fc20    updates  45 M
 
Transaction Summary
================================================================================
Install  5 Packages
 
Total download size: 56 M
Installed size: 92 M
Downloading packages:
(1/5): java-1.8.0-openjdk-accessibility-1.8.0.31-1.b13.fc20 |  12 kB  00:00     
(2/5): java-1.8.0-openjdk-1.8.0.31-1.b13.fc20.x86_64.rpm    | 201 kB  00:02     
(3/5): java-1.8.0-openjdk-demo-1.8.0.31-1.b13.fc20.x86_64.r | 1.9 MB  00:03     
(4/5): java-1.8.0-openjdk-devel-1.8.0.31-1.b13.fc20.x86_64. | 9.2 MB  00:07     
(5/5): java-1.8.0-openjdk-src-1.8.0.31-1.b13.fc20.x86_64.rp |  45 MB  05:05     
--------------------------------------------------------------------------------
Total                                              187 kB/s |  56 MB  05:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : 1:java-1.8.0-openjdk-1.8.0.31-1.b13.fc20.x86_64              1/5 
  Installing : 1:java-1.8.0-openjdk-devel-1.8.0.31-1.b13.fc20.x86_64        2/5 
  Installing : 1:java-1.8.0-openjdk-demo-1.8.0.31-1.b13.fc20.x86_64         3/5 
  Installing : 1:java-1.8.0-openjdk-accessibility-1.8.0.31-1.b13.fc20.x86   4/5 
  Installing : 1:java-1.8.0-openjdk-src-1.8.0.31-1.b13.fc20.x86_64          5/5 
  Verifying  : 1:java-1.8.0-openjdk-devel-1.8.0.31-1.b13.fc20.x86_64        1/5 
  Verifying  : 1:java-1.8.0-openjdk-demo-1.8.0.31-1.b13.fc20.x86_64         2/5 
  Verifying  : 1:java-1.8.0-openjdk-1.8.0.31-1.b13.fc20.x86_64              3/5 
  Verifying  : 1:java-1.8.0-openjdk-accessibility-1.8.0.31-1.b13.fc20.x86   4/5 
  Verifying  : 1:java-1.8.0-openjdk-src-1.8.0.31-1.b13.fc20.x86_64          5/5 
 
Installed:
  java-1.8.0-openjdk.x86_64 1:1.8.0.31-1.b13.fc20                               
  java-1.8.0-openjdk-accessibility.x86_64 1:1.8.0.31-1.b13.fc20                 
  java-1.8.0-openjdk-demo.x86_64 1:1.8.0.31-1.b13.fc20                          
  java-1.8.0-openjdk-devel.x86_64 1:1.8.0.31-1.b13.fc20                         
  java-1.8.0-openjdk-src.x86_64 1:1.8.0.31-1.b13.fc20                           
 
Complete!

Then, you go to Oracle’s SQL Developer 4.0.3 web page or Oracle’s Beta SQL Developer 4.1 web page and download the SQL Developer RPM. At the time of writing, you download the following SQL Developer 4.0.3 RPM:

sqldeveloper-4.0.3.16.84-1.noarch.rpm

Assuming you download the sqldeveloper-4.0.3.16.84-1.noarch.rpm file to the student user’s account. It will download into the /home/student/Downloads directory. You run the SQL Developer RPM file with the following syntax as the root user:

rpm -Uhv /home/student/Downloads/sqldeveloper-4.0.3.16.84-1.noarch.rpm

Running the SQL Developer RPM produces the following output:

Preparing...                          ################################# [100%]
Updating / installing...
   1:sqldeveloper-4.0.3.16.84-1       ################################# [100%]

You can now run the sqldeveloper.sh file as the root user with the following syntax:

/opt/sqldeveloper/sqldeveloper.sh

At this point, it’s important to note that my download from the Oracle SQL Developer 4.1 page turned out to be SQL Developer 4.0.3. It prompts you for the correct Java JDK, as shown below. You may opt to enter the path to the Java JDK 1.8 for SQL Developer 4.1 because until today you downloaded the Oracle SQL Developer 4.0.3 version from the Oracle SQL Developer 4.1 page. Naturally, the Oracle SQL Developer 4.1 instructions say to use the Java 1.8 JDK on the RPM for Linux Installation Notes web page, as shown below:

SQLDevRPMLinuxNotes

If you assume from the instructions on the Oracle instruction page above that Oracle SQL Developer 4.0.3 and Oracle SQL Developer 4.1 support Java 1.8 JDK, you may enter the location for the Java JDK 1.8 when prompted. Jeff Smith, the Product Manager wrote this blog post on Oracle SQL Developer 4: Windows and the JDK. Unfortunately, you’ll see the following message if you attempt to run Oracle SQL Developer 4.0.3 with the Java 1.8 SDK at the command-line:

 Oracle SQL Developer
 Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
 
Type the full pathname of a JDK installation (or Ctrl-C to quit), the path will be stored in /root/.sqldeveloper/4.0.0/product.conf
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31.x86_64
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was removed in 8.0

It also raises the following error message dialog:

SQLDev_JVMErrorMsg

Text version of Unsupported JDK Version error message:

You are attempting to run with Java 1.8.0_31.

Running this product is supported with a minimum Java version of 1.7.0_51 and a maximum version less than 1.8.

Update the SetJavaHome in “/root/.sqldeveloper/4.0.0/product.conf” to point to another Java.

This produce will not be supported, and may not run correctly if you proceed. Continue anyway?

The error dialog message tells us that the instructions on the RPM for Linux Installation Notes web page can be misleading. You really need to use the Java JDK 1.7 to be supported officially, but you can safely ignore the error.

If you want a certified component, leave the “Skip This Message Next Time” checkbox unchecked and click the “No” button to continue. At this point, there’s no automatic recovery. You need to open the following file:

/root/.sqldeveloper/4.0.0/product.conf

You need to change the SetJavaHome parameter in the file to the following:

# SetJavaHome /path/jdk
SetJavaHome /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64

After making the change, you can re-run the sqldeveloper.sh shell as follows:

/opt/sqldeveloper/sqldeveloper.sh

It launches the following dialog message:

SQLDeveloperInstall01

The installation pauses to ask you if you want to transfer an existing SQL Developer configuration by raising the following dialog. Assuming this is a new installation, the installer won’t find a prior configuration file. You need to click the “No” button to proceed.

SQLDevInstallPreferences

The installation continues and launches SQL Developer. The first time launch shows you the following Oracle Usage Tracking dialog. If you don’t want your use monitored, uncheck the “Allow automated usage reporting to Oracle” checkbox. Click the “OK” button to continue.

SQLDevUsageTracking

After dismissing the Oracle Usage Tracking dialog, you see the SQL Developer environment:

SQLDeveloper

After installing SQL Developer in the root account, you can install it as the student user. You use this command as the student user:

/opt/sqldeveloper/sqldeveloper.sh

It returns the following error because it’s the second installation and SQL Developer doesn’t prompt you to configure the user’s product.conf file with the working JDK location:

 Oracle SQL Developer
 Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
 
Type the full pathname of a JDK installation (or Ctrl-C to quit), the path will be stored in /home/student/.sqldeveloper/4.0.0/product.conf
Error:  Unable to get APP_JAVA_HOME input from stdin after 10 tries

You need to edit the /home/student/.sqldeveloper/4.0.0/product.conf file, and add the following line to the file:

# SetJavaHome /path/jdk
SetJavaHome /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79-2.5.5.0.fc20.x86_64

Now, you can launch SQL Developer with the following command:

/opt/sqldeveloper/sqldeveloper.sh

Alternatively, you can add the following alias to the student user’s .bashrc file:

# Set alias for SQL Developer tool.
alias sqldeveloper="/opt/sqldeveloper/sqldeveloper.sh"

You can now launch the SQL Developer tool, like this as the student user:

sqldeveloper

You see the following when SQL Developer launches:

SQLDevInterface

As always, I hope this helps those trying to sort out installing SQL Developer on a Fedora server.

Written by maclochlainn

April 25th, 2015 at 2:38 am

MySQL OCP Exams

with 6 comments

Planning out my year, I decided to take the Oracle OCP and MySQL OCP exams. I checked for review books and was pleasantly surprised to find the soon to be released OCP MySQL Database Administrator Exam Guide (Exam 1Z0-883). However, I noticed that the book was actually prepared for the obsolete and discountinued Exams 1Z0-870, 1Z0-873, and 1Z0-874. As it turns out, Steve O’Hearn has informed me that there isn’t a book and that the posting in Amazon.com is in error.

There isn’t an alternative review book for the OCP MySQL 5.6 Developer or Database Administrator Exams. The question that I have is simple: “How relevant is this book because it was prepared for the older exams?” There isn’t a table of content published on the Amazon.com site. If there was a table of contents it could help me determine how close the book’s content is to the new exam.

As a preparation to figure out the value of the book as a study guide, I’ve reviewed the current Oracle MySQL Training Objectives (listed below). The new MySQL OCP Developer and Administrator exams have the following descriptions and objectives:

  • MySQL 5.6 Developer 1Z0-882. Oracle provides the following outline for their MySQL for Developer (Ed 3) training course:

    Course Objectives

    • Describe the MySQL client/server architecture
    • Use MySQL client programs and common options
    • Program MySQL applications with Java and PHP connectors
    • Use a “NoSQL” approach to store and retrieve data
    • Design efficient tables
    • Create and delete database objects
    • Use expressions in SQL statements
    • Examine database metadata
    • Use SQL statements to modify table data
    • Maintain database integrity with transactions
    • Write multiple table queries
    • Create “virtual tables” containing specific data
    • Create user-defined variables, prepared statements, and stored routines
    • Create and manage triggers
    • Identify and deal with errors and exceptions in client programs
    • Write queries that are fast and effective, even under heavy loads
  • MySQL 5.6 Database Administrator 1Z0-883. Oracle provides the following outline for their MySQL for Database Administrators (Ed 3.1) training course:

    Course Objectives

    • Describe the MySQL Architecture
    • Install and Upgrade MySQL
    • Use the INFORMATION_SCHEMA database to access metadata
    • Perform the MySQL start and shutdown operations
    • Configure MySQL server options at runtime
    • Use available tools including MySQL Workbench
    • Evaluate data types and character sets for performance issues
    • Understand data locking in MySQL
    • Understand the use of the InnoDB storage engine with MySQL
    • Maintain integrity of a MySQL installation
    • Use triggers for administration tasks
    • Use Enterprise Audit and Pluggable Authentication
    • Configure advanced replication topologies for high availability
    • Describe introductory performance tuning techniques
    • Perform backup and restore operations
    • Automate administrative tasks with scheduled events

    As always, I hope this helps those who read it; and, in this case I hope it helps you make an effective decision on preparation resources for the MySQL 5.6 OCP exams.

Written by maclochlainn

April 24th, 2015 at 12:39 am

Oracle Cleanup a Schema

with one comment

Back in January 2014, I wrote a script to cleanup an Oracle student schema. It worked well until I started using APEX 4 in my student schema. You create the following 75 objects when you create an APEX 4 schema.

OBJECT TYPE    TOTAL
------------ -------
TABLE		  17
INDEX		  28
SEQUENCE	   5
TRIGGER 	  14
LOB		   9
FUNCTION	   2

Here’s the modified script that ignores the objects created automatically by Oracle APEX when you create a student workspace:

BEGIN
  FOR i IN (SELECT    object_name
            ,         object_type
            ,         last_ddl_time
            FROM      user_objects
            WHERE     object_name NOT IN
                       ('APEX$_WS_WEBPG_SECTION_HISTORY','APEX$_WS_WEBPG_SECTIONS_T1'
                       ,'APEX$_WS_WEBPG_SECTIONS_PK','APEX$_WS_WEBPG_SECTIONS'
                       ,'APEX$_WS_WEBPG_SECHIST_IDX1','APEX$_WS_TAGS_T1'
                       ,'APEX$_WS_TAGS_PK','APEX$_WS_TAGS_IDX2','APEX$_WS_TAGS_IDX1'
                       ,'APEX$_WS_TAGS','APEX$_WS_ROWS_T1','APEX$_WS_ROWS_PK'
                       ,'APEX$_WS_ROWS_IDX','APEX$_WS_ROWS','APEX$_WS_NOTES_T1'
                       ,'APEX$_WS_NOTES_PK','APEX$_WS_NOTES_IDX2','APEX$_WS_NOTES_IDX1'
                       ,'APEX$_WS_NOTES','APEX$_WS_LINKS_T1','APEX$_WS_LINKS_PK'
                       ,'APEX$_WS_LINKS_IDX2','APEX$_WS_LINKS_IDX1','APEX$_WS_LINKS'
                       ,'APEX$_WS_HISTORY_IDX','APEX$_WS_HISTORY','APEX$_WS_FILES_T1'
                       ,'APEX$_WS_FILES_PK','APEX$_WS_FILES_IDX2','APEX$_WS_FILES_IDX1'
                       ,'APEX$_WS_FILES','APEX$_ACL_T1','APEX$_ACL_PK','APEX$_ACL_IDX1'
                       ,'APEX$_ACL','CUSTOM_AUTH','CUSTOM_HASH','DEPT','EMP'
                       ,'UPDATE_ORDER_TOTAL')
            AND NOT ((object_name LIKE 'DEMO%' OR
                      object_name LIKE 'INSERT_DEMO%' OR
                      object_name LIKE 'BI_DEMO%') AND
                      object_type IN ('TABLE','INDEX','SEQUENCE','TRIGGER'))
            AND NOT (object_name LIKE 'SYS_LOB%' AND object_type = 'LOB')
            AND NOT (object_name LIKE 'SYS_C%' AND object_type = 'INDEX')
            ORDER BY object_type DESC) LOOP
 
    /* Drop types in descending order. */
    IF i.object_type = 'TYPE' THEN
 
      /* Drop type and force operation because dependencies may exist. Oracle 12c
         also fails to remove object types with dependents in pluggable databases
         (at least in release 12.1). Type evolution works in container database
         schemas. */
      EXECUTE IMMEDIATE 'DROP '||i.object_type||' '||i.object_name||' FORCE';
 
    /* Drop table tables in descending order. */
    ELSIF i.object_type = 'TABLE' THEN
 
      /* Drop table with cascading constraints to ensure foreign key constraints
         don't prevent the action. */
      EXECUTE IMMEDIATE 'DROP '||i.object_type||' '||i.object_name||' CASCADE CONSTRAINTS PURGE';
 
      /* Oracle 12c ONLY: Purge the recyclebin to dispose of system-generated
         sequence values because dropping the table doesn't automatically 
         remove them from the active session.
         CRITICAL: Remark out the following when working in Oracle Database 11g. */
      EXECUTE IMMEDIATE 'PURGE RECYCLEBIN';
 
    ELSIF i.object_type = 'LOB' OR i.object_type = 'INDEX' THEN
 
      /* A system generated LOB column or INDEX will cause a failure in a
         generic drop of a table because it is listed in the cursor but removed
         by the drop of its table. This NULL block ensures there is no attempt
         to drop an implicit LOB data type or index because the dropping the
         table takes care of it. */
      NULL;
 
    ELSE
 
      dbms_output.put_line('DROP '||i.object_type||' '||i.object_name||';');
      /* Drop any other objects, like sequences, functions, procedures, and packages. */
      EXECUTE IMMEDIATE 'DROP '||i.object_type||' '||i.object_name;
 
    END IF;
  END LOOP;
END;
/

As always, I hope this helps others.

Written by maclochlainn

April 19th, 2015 at 7:13 pm

Install Ruby on Fedora

with 4 comments

I use a Fedora 20 VM image to teach Oracle and MySQL technology. Last week, I expanded the Fedora VM image to support a full LAMP stack. This blog shows you how to install Ruby on Fedora and successfully generate the Rails gems.

Connect as the root user and use yum to install the libraries. My approach is by library or small groups. Naturally, you start with the ruby library.

yum install ruby

You will see the following:

Loaded plugins: langpacks, refresh-packagekit
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
pgdg93                                                      | 3.6 kB  00:00     
updates/20/x86_64/metalink                                  |  14 kB  00:00     
updates                                                     | 4.9 kB  00:00     
(1/3): mysql56-community/20/x86_64/primary_db               |  80 kB  00:00     
(2/3): pgdg93/20/x86_64/primary_db                          |  80 kB  00:00     
(3/3): updates/20/x86_64/primary_db                         |  13 MB  00:06     
(1/2): updates/20/x86_64/pkgtags                            | 1.4 MB  00:01     
(2/2): updates/20/x86_64/updateinfo                         | 1.9 MB  00:01     
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:2.0.0.353-16.fc20 will be installed
--> Processing Dependency: ruby-libs(x86-64) = 2.0.0.353-16.fc20 for package: ruby-2.0.0.353-16.fc20.x86_64
--> Processing Dependency: rubygem(bigdecimal) >= 1.2.0 for package: ruby-2.0.0.353-16.fc20.x86_64
--> Processing Dependency: ruby(rubygems) >= 2.0.3 for package: ruby-2.0.0.353-16.fc20.x86_64
--> Processing Dependency: /usr/bin/ruby for package: ruby-2.0.0.353-16.fc20.x86_64
--> Processing Dependency: libruby.so.2.0()(64bit) for package: ruby-2.0.0.353-16.fc20.x86_64
--> Running transaction check
---> Package ruby-libs.x86_64 0:2.0.0.353-16.fc20 will be installed
---> Package rubygem-bigdecimal.x86_64 0:1.2.0-16.fc20 will be installed
---> Package rubygems.noarch 0:2.1.11-115.fc20 will be installed
--> Processing Dependency: rubygem(rdoc) >= 4.0.0 for package: rubygems-2.1.11-115.fc20.noarch
--> Processing Dependency: rubygem(psych) >= 2.0.0 for package: rubygems-2.1.11-115.fc20.noarch
--> Processing Dependency: rubygem(io-console) >= 0.4.1 for package: rubygems-2.1.11-115.fc20.noarch
---> Package rubypick.noarch 0:1.1.1-1.fc20 will be installed
--> Running transaction check
---> Package rubygem-io-console.x86_64 0:0.4.2-16.fc20 will be installed
---> Package rubygem-psych.x86_64 0:2.0.0-16.fc20 will be installed
--> Processing Dependency: libyaml-0.so.2()(64bit) for package: rubygem-psych-2.0.0-16.fc20.x86_64
---> Package rubygem-rdoc.noarch 0:4.0.1-2.fc20 will be installed
--> Processing Dependency: rubygem(json) < 2 for package: rubygem-rdoc-4.0.1-2.fc20.noarch
--> Processing Dependency: rubygem(json) >= 1.4 for package: rubygem-rdoc-4.0.1-2.fc20.noarch
--> Processing Dependency: ruby(irb) for package: rubygem-rdoc-4.0.1-2.fc20.noarch
--> Running transaction check
---> Package libyaml.x86_64 0:0.1.6-2.fc20 will be installed
---> Package ruby-irb.noarch 0:2.0.0.353-16.fc20 will be installed
---> Package rubygem-json.x86_64 0:1.7.7-101.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                 Arch        Version                 Repository    Size
================================================================================
Installing:
 ruby                    x86_64      2.0.0.353-16.fc20       updates       65 k
Installing for dependencies:
 libyaml                 x86_64      0.1.6-2.fc20            updates       55 k
 ruby-irb                noarch      2.0.0.353-16.fc20       updates       86 k
 ruby-libs               x86_64      2.0.0.353-16.fc20       updates      2.8 M
 rubygem-bigdecimal      x86_64      1.2.0-16.fc20           updates       77 k
 rubygem-io-console      x86_64      0.4.2-16.fc20           updates       48 k
 rubygem-json            x86_64      1.7.7-101.fc20          fedora        60 k
 rubygem-psych           x86_64      2.0.0-16.fc20           updates       75 k
 rubygem-rdoc            noarch      4.0.1-2.fc20            fedora       288 k
 rubygems                noarch      2.1.11-115.fc20         updates      224 k
 rubypick                noarch      1.1.1-1.fc20            updates      6.3 k
 
Transaction Summary
================================================================================
Install  1 Package (+10 Dependent packages)
 
Total download size: 3.7 M
Installed size: 13 M
Is this ok [y/d/N]: y
Downloading packages:
(1/11): ruby-2.0.0.353-16.fc20.x86_64.rpm                   |  65 kB  00:00     
(2/11): libyaml-0.1.6-2.fc20.x86_64.rpm                     |  55 kB  00:00     
(3/11): ruby-irb-2.0.0.353-16.fc20.noarch.rpm               |  86 kB  00:00     
(4/11): rubygem-io-console-0.4.2-16.fc20.x86_64.rpm         |  48 kB  00:00     
(5/11): rubygem-json-1.7.7-101.fc20.x86_64.rpm              |  60 kB  00:00     
(6/11): rubygem-psych-2.0.0-16.fc20.x86_64.rpm              |  75 kB  00:00     
(7/11): rubypick-1.1.1-1.fc20.noarch.rpm                    | 6.3 kB  00:00     
(8/11): rubygem-bigdecimal-1.2.0-16.fc20.x86_64.rpm         |  77 kB  00:01     
(9/11): rubygem-rdoc-4.0.1-2.fc20.noarch.rpm                | 288 kB  00:00     
(10/11): ruby-libs-2.0.0.353-16.fc20.x86_64.rpm             | 2.8 MB  00:01     
(11/11): rubygems-2.1.11-115.fc20.noarch.rpm                | 224 kB  00:01     
--------------------------------------------------------------------------------
Total                                              1.4 MB/s | 3.7 MB  00:02     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : ruby-libs-2.0.0.353-16.fc20.x86_64                          1/11 
  Installing : libyaml-0.1.6-2.fc20.x86_64                                 2/11 
  Installing : rubygem-bigdecimal-1.2.0-16.fc20.x86_64                     3/11 
  Installing : rubygem-json-1.7.7-101.fc20.x86_64                          4/11 
  Installing : rubygem-psych-2.0.0-16.fc20.x86_64                          5/11 
  Installing : rubygem-rdoc-4.0.1-2.fc20.noarch                            6/11 
  Installing : ruby-irb-2.0.0.353-16.fc20.noarch                           7/11 
  Installing : rubypick-1.1.1-1.fc20.noarch                                8/11 
  Installing : ruby-2.0.0.353-16.fc20.x86_64                               9/11 
  Installing : rubygems-2.1.11-115.fc20.noarch                            10/11 
  Installing : rubygem-io-console-0.4.2-16.fc20.x86_64                    11/11 
  Verifying  : rubygem-io-console-0.4.2-16.fc20.x86_64                     1/11 
  Verifying  : rubygem-rdoc-4.0.1-2.fc20.noarch                            2/11 
  Verifying  : rubygems-2.1.11-115.fc20.noarch                             3/11 
  Verifying  : rubygem-bigdecimal-1.2.0-16.fc20.x86_64                     4/11 
  Verifying  : ruby-libs-2.0.0.353-16.fc20.x86_64                          5/11 
  Verifying  : rubygem-json-1.7.7-101.fc20.x86_64                          6/11 
  Verifying  : rubygem-psych-2.0.0-16.fc20.x86_64                          7/11 
  Verifying  : rubypick-1.1.1-1.fc20.noarch                                8/11 
  Verifying  : ruby-2.0.0.353-16.fc20.x86_64                               9/11 
  Verifying  : libyaml-0.1.6-2.fc20.x86_64                                10/11 
  Verifying  : ruby-irb-2.0.0.353-16.fc20.noarch                          11/11 
 
Installed:
  ruby.x86_64 0:2.0.0.353-16.fc20                                               
 
Dependency Installed:
  libyaml.x86_64 0:0.1.6-2.fc20                                                 
  ruby-irb.noarch 0:2.0.0.353-16.fc20                                           
  ruby-libs.x86_64 0:2.0.0.353-16.fc20                                          
  rubygem-bigdecimal.x86_64 0:1.2.0-16.fc20                                     
  rubygem-io-console.x86_64 0:0.4.2-16.fc20                                     
  rubygem-json.x86_64 0:1.7.7-101.fc20                                          
  rubygem-psych.x86_64 0:2.0.0-16.fc20                                          
  rubygem-rdoc.noarch 0:4.0.1-2.fc20                                            
  rubygems.noarch 0:2.1.11-115.fc20                                             
  rubypick.noarch 0:1.1.1-1.fc20                                                
 
Complete!

After you install ruby, you need to install the MySQL and Ruby development libraries, like this:

yum -y install gcc mysql-devel ruby-devel rubygems
Loaded plugins: langpacks, refresh-packagekit
Package gcc-4.8.3-7.fc20.x86_64 already installed and latest version
Package rubygems-2.1.11-115.fc20.noarch already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package mysql-community-devel.x86_64 0:5.6.24-1.fc20 will be installed
--> Processing Dependency: mysql-community-libs(x86-64) = 5.6.24-1.fc20 for package: mysql-community-devel-5.6.24-1.fc20.x86_64
---> Package ruby-devel.x86_64 0:2.0.0.353-16.fc20 will be installed
--> Running transaction check
---> Package mysql-community-libs.x86_64 0:5.6.23-1.fc20 will be updated
--> Processing Dependency: mysql-community-libs(x86-64) = 5.6.23-1.fc20 for package: mysql-community-client-5.6.23-1.fc20.x86_64
---> Package mysql-community-libs.x86_64 0:5.6.24-1.fc20 will be an update
--> Processing Dependency: mysql-community-common(x86-64) = 5.6.24-1.fc20 for package: mysql-community-libs-5.6.24-1.fc20.x86_64
--> Running transaction check
---> Package mysql-community-client.x86_64 0:5.6.23-1.fc20 will be updated
--> Processing Dependency: mysql-community-client(x86-64) = 5.6.23-1.fc20 for package: mysql-community-server-5.6.23-1.fc20.x86_64
---> Package mysql-community-client.x86_64 0:5.6.24-1.fc20 will be an update
---> Package mysql-community-common.x86_64 0:5.6.23-1.fc20 will be updated
---> Package mysql-community-common.x86_64 0:5.6.24-1.fc20 will be an update
--> Running transaction check
---> Package mysql-community-server.x86_64 0:5.6.23-1.fc20 will be updated
---> Package mysql-community-server.x86_64 0:5.6.24-1.fc20 will be an update
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                 Arch    Version               Repository          Size
================================================================================
Installing:
 mysql-community-devel   x86_64  5.6.24-1.fc20         mysql56-community  3.4 M
 ruby-devel              x86_64  2.0.0.353-16.fc20     updates            125 k
Updating for dependencies:
 mysql-community-client  x86_64  5.6.24-1.fc20         mysql56-community   19 M
 mysql-community-common  x86_64  5.6.24-1.fc20         mysql56-community  258 k
 mysql-community-libs    x86_64  5.6.24-1.fc20         mysql56-community  2.0 M
 mysql-community-server  x86_64  5.6.24-1.fc20         mysql56-community   55 M
 
Transaction Summary
================================================================================
Install  2 Packages
Upgrade             ( 4 Dependent packages)
 
Total download size: 80 M
Downloading packages:
No Presto metadata available for mysql56-community
(1/6): mysql-community-common-5.6.24-1.fc20.x86_64.rpm      | 258 kB  00:01     
(2/6): mysql-community-devel-5.6.24-1.fc20.x86_64.rpm       | 3.4 MB  00:01     
(3/6): mysql-community-libs-5.6.24-1.fc20.x86_64.rpm        | 2.0 MB  00:00     
(4/6): ruby-devel-2.0.0.353-16.fc20.x86_64.rpm              | 125 kB  00:00     
(5/6): mysql-community-client-5.6.24-1.fc20.x86_64.rpm      |  19 MB  00:09     
(6/6): mysql-community-server-5.6.24-1.fc20.x86_64.rpm      |  55 MB  00:21     
--------------------------------------------------------------------------------
Total                                              3.3 MB/s |  80 MB  00:24     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Updating   : mysql-community-common-5.6.24-1.fc20.x86_64                 1/10 
  Updating   : mysql-community-libs-5.6.24-1.fc20.x86_64                   2/10 
  Updating   : mysql-community-client-5.6.24-1.fc20.x86_64                 3/10 
  Updating   : mysql-community-server-5.6.24-1.fc20.x86_64                 4/10 
  Installing : mysql-community-devel-5.6.24-1.fc20.x86_64                  5/10 
  Installing : ruby-devel-2.0.0.353-16.fc20.x86_64                         6/10 
  Cleanup    : mysql-community-server-5.6.23-1.fc20.x86_64                 7/10 
  Cleanup    : mysql-community-client-5.6.23-1.fc20.x86_64                 8/10 
  Cleanup    : mysql-community-libs-5.6.23-1.fc20.x86_64                   9/10 
  Cleanup    : mysql-community-common-5.6.23-1.fc20.x86_64                10/10 
  Verifying  : mysql-community-client-5.6.24-1.fc20.x86_64                 1/10 
  Verifying  : mysql-community-devel-5.6.24-1.fc20.x86_64                  2/10 
  Verifying  : ruby-devel-2.0.0.353-16.fc20.x86_64                         3/10 
  Verifying  : mysql-community-libs-5.6.24-1.fc20.x86_64                   4/10 
  Verifying  : mysql-community-common-5.6.24-1.fc20.x86_64                 5/10 
  Verifying  : mysql-community-server-5.6.24-1.fc20.x86_64                 6/10 
  Verifying  : mysql-community-client-5.6.23-1.fc20.x86_64                 7/10 
  Verifying  : mysql-community-server-5.6.23-1.fc20.x86_64                 8/10 
  Verifying  : mysql-community-libs-5.6.23-1.fc20.x86_64                   9/10 
  Verifying  : mysql-community-common-5.6.23-1.fc20.x86_64                10/10 
 
Installed:
  mysql-community-devel.x86_64 0:5.6.24-1.fc20                                  
  ruby-devel.x86_64 0:2.0.0.353-16.fc20                                         
 
Dependency Updated:
  mysql-community-client.x86_64 0:5.6.24-1.fc20                                 
  mysql-community-common.x86_64 0:5.6.24-1.fc20                                 
  mysql-community-libs.x86_64 0:5.6.24-1.fc20                                   
  mysql-community-server.x86_64 0:5.6.24-1.fc20                                 
 
Complete!

After installing ruby, exit the root account to your management account and run the following command from the Linux shell:

ruby -v

It should show you:

ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]

Before you can run gem to install rails, you must install another the libxml2-devel library. Here’s the syntax to install the libxml2-devel library:

yum install libxml2-devel

You should see the following, which includes typing a y to continue:

Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package libxml2-devel.x86_64 0:2.9.1-3.fc20 will be installed
--> Processing Dependency: zlib-devel for package: libxml2-devel-2.9.1-3.fc20.x86_64
--> Processing Dependency: xz-devel for package: libxml2-devel-2.9.1-3.fc20.x86_64
--> Running transaction check
---> Package xz-devel.x86_64 0:5.1.2-12alpha.fc20 will be installed
---> Package zlib-devel.x86_64 0:1.2.8-3.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package             Arch         Version                   Repository     Size
================================================================================
Installing:
 libxml2-devel       x86_64       2.9.1-3.fc20              updates       1.0 M
Installing for dependencies:
 xz-devel            x86_64       5.1.2-12alpha.fc20        updates        45 k
 zlib-devel          x86_64       1.2.8-3.fc20              fedora         50 k
 
Transaction Summary
================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 1.1 M
Installed size: 9.1 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): xz-devel-5.1.2-12alpha.fc20.x86_64.rpm               |  45 kB  00:00     
(2/3): zlib-devel-1.2.8-3.fc20.x86_64.rpm                   |  50 kB  00:00     
(3/3): libxml2-devel-2.9.1-3.fc20.x86_64.rpm                | 1.0 MB  00:04     
--------------------------------------------------------------------------------
Total                                              264 kB/s | 1.1 MB  00:04     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : zlib-devel-1.2.8-3.fc20.x86_64                               1/3 
  Installing : xz-devel-5.1.2-12alpha.fc20.x86_64                           2/3 
  Installing : libxml2-devel-2.9.1-3.fc20.x86_64                            3/3 
  Verifying  : xz-devel-5.1.2-12alpha.fc20.x86_64                           1/3 
  Verifying  : libxml2-devel-2.9.1-3.fc20.x86_64                            2/3 
  Verifying  : zlib-devel-1.2.8-3.fc20.x86_64                               3/3 
 
Installed:
  libxml2-devel.x86_64 0:2.9.1-3.fc20                                           
 
Dependency Installed:
  xz-devel.x86_64 0:5.1.2-12alpha.fc20     zlib-devel.x86_64 0:1.2.8-3.fc20    
 
Complete!
yum install libxslt-devel

You should see the following and will need to reply with a y during install:

Loaded plugins: langpacks, refresh-packagekit
mysql-connectors-community                                  | 2.5 kB  00:00     
mysql-tools-community                                       | 2.5 kB  00:00     
mysql56-community                                           | 2.5 kB  00:00     
pgdg93                                                      | 3.6 kB  00:00     
updates/20/x86_64/metalink                                  |  14 kB  00:00     
updates                                                     | 4.9 kB  00:00     
updates/20/x86_64/primary_db                                |  13 MB  00:07     
updates/20/x86_64/pkgtags      FAILED                                           
http://mirror.utexas.edu/fedora/linux/updates/20/x86_64/repodata/fe40e35e0289ae1470dbe8030c09b8046924cbaa5e16ac61e9411ac57477820b-pkgtags.sqlite.gz: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
(1/2): updates/20/x86_64/updateinfo                         | 1.9 MB  00:02     
(2/2): updates/20/x86_64/pkgtags                            | 1.4 MB  00:00     
Resolving Dependencies
--> Running transaction check
---> Package libxslt-devel.x86_64 0:1.1.28-5.fc20 will be installed
--> Processing Dependency: libgcrypt-devel for package: libxslt-devel-1.1.28-5.fc20.x86_64
--> Running transaction check
---> Package libgcrypt-devel.x86_64 0:1.5.3-2.fc20 will be installed
--> Processing Dependency: libgpg-error-devel for package: libgcrypt-devel-1.5.3-2.fc20.x86_64
--> Running transaction check
---> Package libgpg-error-devel.x86_64 0:1.12-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                  Arch         Version               Repository    Size
================================================================================
Installing:
 libxslt-devel            x86_64       1.1.28-5.fc20         fedora       309 k
Installing for dependencies:
 libgcrypt-devel          x86_64       1.5.3-2.fc20          fedora       127 k
 libgpg-error-devel       x86_64       1.12-1.fc20           fedora        16 k
 
Transaction Summary
================================================================================
Install  1 Package (+2 Dependent packages)
 
Total download size: 451 k
Installed size: 2.6 M
Is this ok [y/d/N]: y
Downloading packages:
(1/3): libgcrypt-devel-1.5.3-2.fc20.x86_64.rpm              | 127 kB  00:00     
(2/3): libgpg-error-devel-1.12-1.fc20.x86_64.rpm            |  16 kB  00:00     
(3/3): libxslt-devel-1.1.28-5.fc20.x86_64.rpm               | 309 kB  00:00     
--------------------------------------------------------------------------------
Total                                              454 kB/s | 451 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : libgpg-error-devel-1.12-1.fc20.x86_64                        1/3 
  Installing : libgcrypt-devel-1.5.3-2.fc20.x86_64                          2/3 
  Installing : libxslt-devel-1.1.28-5.fc20.x86_64                           3/3 
  Verifying  : libgcrypt-devel-1.5.3-2.fc20.x86_64                          1/3 
  Verifying  : libgpg-error-devel-1.12-1.fc20.x86_64                        2/3 
  Verifying  : libxslt-devel-1.1.28-5.fc20.x86_64                           3/3 
 
Installed:
  libxslt-devel.x86_64 0:1.1.28-5.fc20                                          
 
Dependency Installed:
  libgcrypt-devel.x86_64 0:1.5.3-2.fc20 libgpg-error-devel.x86_64 0:1.12-1.fc20
 
Complete!

One more to go. You can’t run the Ruby gem utility to create the nokogiri Ruby Gem on Fedora because of a library mismatch. If you attempt to create the Rails framework, like this:

gem install rails

It’ll raise the following error message on trying to dynamically link the nokogiri Ruby Gem. The error will be something like this, and unfortunately, the log files won’t be too useful:

Running patch with /usr/local/share/gems/gems/nokogiri-1.6.6.2/ports/patches/libxml2/0001-Revert-Missing-initialization-for-the-catalog-module.patch...
Running 'patch' for libxml2 2.9.2... ERROR, review '/usr/local/share/gems/gems/nokogiri-1.6.6.2/ext/nokogiri/tmp/x86_64-redhat-linux-gnu/ports/libxml2/2.9.2/patch.log' to see what happened.
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

The error message isn’t very helpful but the fix is fortunately easy. You install the nokogiri Ruby Gem directly with the yum utility. The following instructs yum to proceed without waiting for you to type a y to install.

yum install -y rubygem-nokogiri
Loaded plugins: langpacks, refresh-packagekit
Resolving Dependencies
--> Running transaction check
---> Package rubygem-nokogiri.x86_64 0:1.6.6.2-1.fc20 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                Arch         Version                Repository     Size
================================================================================
Installing:
 rubygem-nokogiri       x86_64       1.6.6.2-1.fc20         updates       534 k
 
Transaction Summary
================================================================================
Install  1 Package
 
Total download size: 534 k
Installed size: 834 k
Downloading packages:
rubygem-nokogiri-1.6.6.2-1.fc20.x86_64.rpm                  | 534 kB  00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction (shutdown inhibited)
  Installing : rubygem-nokogiri-1.6.6.2-1.fc20.x86_64                       1/1 
  Verifying  : rubygem-nokogiri-1.6.6.2-1.fc20.x86_64                       1/1 
 
Installed:
  rubygem-nokogiri.x86_64 0:1.6.6.2-1.fc20                                      
 
Complete!

Now you can use the Ruby gem utility to create the Rails framework like this:

gem install rails

This will take a couple minutes typically, so be patient. You see something like this, dependent on the release:

Fetching: loofah-2.0.1.gem (100%)
Successfully installed loofah-2.0.1
Fetching: rails-html-sanitizer-1.0.2.gem (100%)
Successfully installed rails-html-sanitizer-1.0.2
Fetching: rails-deprecated_sanitizer-1.0.3.gem (100%)
Successfully installed rails-deprecated_sanitizer-1.0.3
Fetching: rails-dom-testing-1.0.6.gem (100%)
Successfully installed rails-dom-testing-1.0.6
Fetching: builder-3.2.2.gem (100%)
Successfully installed builder-3.2.2
Fetching: erubis-2.7.0.gem (100%)
Successfully installed erubis-2.7.0
Fetching: actionview-4.2.1.gem (100%)
Successfully installed actionview-4.2.1
Fetching: actionpack-4.2.1.gem (100%)
Successfully installed actionpack-4.2.1
Fetching: activemodel-4.2.1.gem (100%)
Successfully installed activemodel-4.2.1
Fetching: arel-6.0.0.gem (100%)
Successfully installed arel-6.0.0
Fetching: activerecord-4.2.1.gem (100%)
Successfully installed activerecord-4.2.1
Fetching: globalid-0.3.5.gem (100%)
Successfully installed globalid-0.3.5
Fetching: activejob-4.2.1.gem (100%)
Successfully installed activejob-4.2.1
Fetching: mime-types-2.4.3.gem (100%)
Successfully installed mime-types-2.4.3
Fetching: mail-2.6.3.gem (100%)
Successfully installed mail-2.6.3
Fetching: actionmailer-4.2.1.gem (100%)
Successfully installed actionmailer-4.2.1
Fetching: rake-10.4.2.gem (100%)
Successfully installed rake-10.4.2
Fetching: thor-0.19.1.gem (100%)
Successfully installed thor-0.19.1
Fetching: railties-4.2.1.gem (100%)
Successfully installed railties-4.2.1
Fetching: bundler-1.9.2.gem (100%)
Successfully installed bundler-1.9.2
Fetching: hike-1.2.3.gem (100%)
Successfully installed hike-1.2.3
Fetching: multi_json-1.11.0.gem (100%)
Successfully installed multi_json-1.11.0
Fetching: tilt-1.4.1.gem (100%)
Successfully installed tilt-1.4.1
Fetching: sprockets-2.12.3.gem (100%)
Successfully installed sprockets-2.12.3
Fetching: sprockets-rails-2.2.4.gem (100%)
Successfully installed sprockets-rails-2.2.4
Fetching: rails-4.2.1.gem (100%)
Successfully installed rails-4.2.1
Parsing documentation for actionmailer-4.2.1
Installing ri documentation for actionmailer-4.2.1
Parsing documentation for actionpack-4.2.1
Installing ri documentation for actionpack-4.2.1
Parsing documentation for actionview-4.2.1
Installing ri documentation for actionview-4.2.1
Parsing documentation for activejob-4.2.1
Installing ri documentation for activejob-4.2.1
Parsing documentation for activemodel-4.2.1
Installing ri documentation for activemodel-4.2.1
Parsing documentation for activerecord-4.2.1
Installing ri documentation for activerecord-4.2.1
Parsing documentation for arel-6.0.0
Installing ri documentation for arel-6.0.0
Parsing documentation for builder-3.2.2
Installing ri documentation for builder-3.2.2
Parsing documentation for bundler-1.9.2
Installing ri documentation for bundler-1.9.2
Parsing documentation for erubis-2.7.0
Installing ri documentation for erubis-2.7.0
Parsing documentation for globalid-0.3.5
Installing ri documentation for globalid-0.3.5
Parsing documentation for hike-1.2.3
Installing ri documentation for hike-1.2.3
Parsing documentation for loofah-2.0.1
Installing ri documentation for loofah-2.0.1
Parsing documentation for mail-2.6.3
Installing ri documentation for mail-2.6.3
Parsing documentation for mime-types-2.4.3
Installing ri documentation for mime-types-2.4.3
Parsing documentation for multi_json-1.11.0
Installing ri documentation for multi_json-1.11.0
Parsing documentation for rails-4.2.1
Installing ri documentation for rails-4.2.1
Parsing documentation for rails-deprecated_sanitizer-1.0.3
Installing ri documentation for rails-deprecated_sanitizer-1.0.3
Parsing documentation for rails-dom-testing-1.0.6
Installing ri documentation for rails-dom-testing-1.0.6
Parsing documentation for rails-html-sanitizer-1.0.2
Installing ri documentation for rails-html-sanitizer-1.0.2
Parsing documentation for railties-4.2.1
Installing ri documentation for railties-4.2.1
Parsing documentation for rake-10.4.2
Installing ri documentation for rake-10.4.2
Parsing documentation for sprockets-2.12.3
Installing ri documentation for sprockets-2.12.3
Parsing documentation for sprockets-rails-2.2.4
Installing ri documentation for sprockets-rails-2.2.4
Parsing documentation for thor-0.19.1
Installing ri documentation for thor-0.19.1
Parsing documentation for tilt-1.4.1
Installing ri documentation for tilt-1.4.1
Done installing documentation for actionmailer, actionpack, actionview, activejob, activemodel, activerecord, arel, builder, bundler, erubis, globalid, hike, loofah, mail, mime-types, multi_json, rails, rails-deprecated_sanitizer, rails-dom-testing, rails-html-sanitizer, railties, rake, sprockets, sprockets-rails, thor, tilt after 475 seconds
26 gems installed

If you want to install Phusion Passenger, mod_passenger is already installed. You should note that support and testing for this stops at Fedora V17. You can verify installation with the following command:

yum list mod_passenger

It returns:

Loaded plugins: langpacks, refresh-packagekit
Available Packages
mod_passenger.x86_64                   4.0.53-3.fc20.2                   updates

You can also install the Ruby Gem for Passenger, like this:

gem install passenger

It should take less than 2 minutes and return something like this:

Fetching: passenger-5.0.6.gem (100%)
Building native extensions.  This could take a while...
Successfully installed passenger-5.0.6
Parsing documentation for passenger-5.0.6
Installing ri documentation for passenger-5.0.6
Done installing documentation for passenger after 9 seconds
1 gem installed

As always, I hope this was helpful. I’ll add a post with the remaining MySQL and Oracle connection details soon.

Written by maclochlainn

April 10th, 2015 at 2:28 am

APEX Create Table

with 2 comments

The following walks you through how you sign on to a STUDENT Workspace with Oracle’s APEX product. It shows you how to create a new table with the Object Browser tool.

You can find instructions on how to create your own STUDENT Workspace in this blog post. Overall, Oracle APEX is a valuable tool to learn and master.

UseStudentAPEX01

  1. You start the process by accessing the Oracle Database 11g APEX, which you can access at http://localhost:8080/apex by default on the server. If you’ve got a static IP address for your instance, you can replace localhost with the IP address or hostname for the IP address.

    • Workspace: STUDENT
    • Username:  ADMIN
    • Password:  STUDENT

UseStudentAPEX02

  1. After you login to the STUDENT workspace, you have four options. They are the: Application Builder, SQL Workshop, Team Development, and Administration. You start the process by accessing the Oracle Database 11g APEX, which you can access at http://localhost:8080/apex by default on the server. If you’ve got a static IP address for your instance, you can replace localhost with the IP address or hostname for the IP address. Click on the Object Browser icon to proceed.

UseStudentAPEX02A

  1. Clicking the SQL Workshop icon takes you to the second level menu. You click the Object Browser icon to create a database object.

OracleAPEXCT01

  1. After clicking the Object Browser icon, you see the screen at the left. Click the Create button to create a table.

OracleAPEXCT02

  1. After clicking the Create button, you see the screen at the left. Click the type of database object that you want to create. In our case, we click the Table hypertext to start the create table workflow.

OracleAPEXCT03

  1. After clicking the Table hyperlink, you see the Create Table screen at the left. Enter the column names, choose their data types and set the scale and precision. You should also check the Not Null checkbox when you want a column to be mandatory. Click the Next button to continue the create table workflow.

OracleAPEXCT04

  1. After entering the column names, you should choose the data types, enter the scale and precision, and check the NOT NULL checkbox to make appropriate columns mandatory by applying NOT NULL database constraints. If you run out of entry rows, you can click the Add Column button to add new rows. Click the Next button to continue the create table workflow when you’ve defined the columns.

OracleAPEXCT05

  1. After defining the column names, you should choose whether the primary key will use a new sequence or an existing sequence. You also have the ability to not assign a primary key value or simply leave it unpopulated when inserting new rows. The example creates an IMAGE_PK primary key constraint on the IMAGE_ID column, and declares an IMAGE_SEQ sequence value. Click the Next button to continue the create table workflow when you’ve defined the primary key constraint and any new sequence value for the primary key column.

OracleAPEXCTFK1

  1. After defining the primary key constraint, you can define foreign key column constraints. You enter a foreign key constraint name, choose between a Disallow Delete, Cascade Delete, or Set Null on Delete rule, select the foreign key column, the foreign key’s referenced table and column. Click the Add button to continue the create table workflow.

OracleAPEXCTFK2

  1. After defining a foreign key constraint, you can see the constraint that you created. Then, you can define another foreign key column constraints. You repeat the steps from the prior steps to add another foreign key constraint. Click the Add button to create a second foreign key constraint and complete the create table workflow.

OracleAPEXCTFK3

  1. After defining a second foreign key constraint, you see the following two foreign key constraints. Click the Next button to complete the create table workflow.

OracleAPEXTCUK01

  1. After defining all the foreign key constraints, you can create check and unique constraints. You check a radio button for a check or unique constraint, and then you select the columns for the constraint’s key. Click the /Add button to create any check or unique constraints as part of the create table workflow.

OracleAPEXTCUK02

  1. After defining all check and unique key constraints, you can see them in the Constraints box. Click the Next button to complete the create table workflow.

OracleAPEXCTC01

  1. After defining all items about the table, you can see the SQL to create the IMAGE table and its constraints. You can copy the SQL into a file for later use when writing a re-runnable script. Click the Create button to complete the create table workflow and create the table.

     

    The following are the contents of the script for the actions you’ve defined:

    CREATE table "IMAGE" (
        "IMAGE_ID"         NUMBER NOT NULL,
        "FILE_NAME"        VARCHAR2(60) NOT NULL,
        "MIME_TYPE"        NUMBER NOT NULL,
        "ITEM_IMAGE"       BLOB,
        "CREATED_BY"       NUMBER NOT NULL,
        "CREATION_DATE"    DATE NOT NULL,
        "LAST_UPDATED_BY"  NUMBER NOT NULL,
        "LAST_UPDATE_DATE" DATE NOT NULL,
        constraint  "IMAGE_PK" primary key ("IMAGE_ID")
    )
    /
    
    CREATE sequence "IMAGE_SEQ" 
    /
    
    CREATE trigger "BI_IMAGE"  
      before insert on "IMAGE"              
      for each row 
    begin  
      if :NEW."IMAGE_ID" is null then
        select "IMAGE_SEQ".nextval into :NEW."IMAGE_ID" from dual;
      end if;
    end;
    /   
    
    ALTER TABLE "IMAGE" ADD CONSTRAINT "IMAGE_FK1" 
    FOREIGN KEY ("CREATED_BY")
    REFERENCES "SYSTEM_USER" ("SYSTEM_USER_ID")
    
    /
    ALTER TABLE "IMAGE" ADD CONSTRAINT "IMAGE_FK2" 
    FOREIGN KEY ("LAST_UPDATED_BY")
    REFERENCES "SYSTEM_USER" ("SYSTEM_USER_ID")
    
    /
    alter table "IMAGE" add
    constraint "IMAGE_UK1" 
    unique ("FILE_NAME","MIME_TYPE")
    /   
    

OracleAPEXTable

  1. After creating the table, trigger, sequence, and constraints, you can see the table definition. You also have the ability to modify the table. At this point, you can create another structure or you can click the Home or SQL Workshop menu choice.

As always, I hope this helps those looking to learn new things and approaches.

Written by maclochlainn

April 7th, 2015 at 10:21 pm

APEX SQL Query

without comments

The following walks through how you sign on to a STUDENT Workspace with Oracle’s APEX product and write and run free-form SQL statements. You can find instructions on how to create your own STUDENT Workspace.

While this blog introduces several concepts and features of Oracle APEX, it only focuses on how to write and run free-form SQL statements. Overall, Oracle APEX is a valuable tool to learn and master.

UseStudentAPEX01

  1. You start the process by accessing the Oracle Database 11g APEX, which you can access at http://localhost:8080/apex by default on the server. If you’ve got a static IP address for your instance, you can replace localhost with the IP address or hostname for the IP address.

    • Workspace: STUDENT
    • Username:  ADMIN
    • Password:  STUDENT

UseStudentAPEX02

  1. After you login to the STUDENT workspace, you have four options. They are the: Application Builder, SQL Workshop, Team Development, and Administration. You start the process by accessing the Oracle Database 11g APEX, which you can access at http://localhost:8080/apex by default on the server. If you’ve got a static IP address for your instance, you can replace localhost with the IP address or hostname for the IP address. Click on the SQL Workshop icon to proceed.

    • Application Builder: Let’s you build custom APEX applications.
    • SQL Workshop: Let’s you work with custom SQL, and APEX provides you with the following utilities:
      • Object Browser: Lets you create tables, views, and other objects.
      • SQL Commands: Lets you run individual SQL statements inside a browser window and returns results in the bottom pane.
      • SQL Scripts: Lets you create, upload, delete, and run scripts from the browser.
      • Query Builder: Lets you create free form queries that include joins between tables, but limits you to primary to foreign key table relationships. That means you can’t write range joins with a cross join and the BETWEEN operator and you can’t write self-joins.
      • Utilities: Lets you work with the Data Workshop (imports and exports data), Object Reports (a SQL report writer tool), Generate DDL (a tool that creates structures in the database), User Interface Defaults (coordinate data dictionary), Schema Comparison (a tool to compare similarities between schemas, About Database (the ability to connect as the database administrator), and Recycle Bin (dropped and purged structures).
    • Team Development: A project management tool.
    • Administration: Lets you manage database services, users and groups, monitor activities, and dashboards. You should note that the SQL query doesn’t have a semicolon like it would in a SQL*Plus environment. The Run button acts as the execution operator and effectively replaces the role of the semicolon, which traditionally executes a statement.

UseStudentAPEX02A

  1. Clicking the SQL Workshop icon takes you to the second level menu. You click the SQL Commands icon to enter a free-form SQL statement. Click on the SQL Commands icon to proceed.

UseStudentAPEX03

  1. The first text panel lets you enter free-form queries. The Autocommit checkbox is enabled, which means the result of INSERT and UPDATE statements are immediate and don’t require a COMMIT statement. The second text panel displays results from a query or acknowledgment of statement completion.

UseStudentAPEX04

  1. This screen shot shows a query in the first panel and the results of the query in the second panel.

As always, I hope this helps those looking to learn new things and approaches.

Written by maclochlainn

April 5th, 2015 at 4:36 pm

APEX Create Workspace

with 2 comments

In a prior post, I showed you how to access Oracle Database 11g XE APEX. This post shows you how to create a basic workspace against a student database (or, what Oracle lables a schema, which is synonymous with a database).

Oracle11gAPEX_01

  1. You start the process by accessing the Oracle Database 11g APEX, which you can access at http://localhost:8080/apex by default on the server. If you’ve got a static IP address for your instance, you can replace localhost with the IP address or hostname for the IP address.

    • Workspace: INTERNAL
    • Username:  ADMIN
    • Password:  installation_system_password

Oracle11gAPEX_02

  1. After logging into the Oracle Application Express (APEX) system, you see the Home page at the left. Click the Manage Workspace button on the Home page.

Oracle11gAPEX_03

  1. Manage Workspace Dialog: After clicking the Manage Workspace button on the Home page, you see four major options to manage workspaces. They are the Workspace Actions, Workspace Reports, Export Import, and Manage Applications. You want to click on the Create Workspace to create a new workspace.

Oracle11gAPEX_03A

  1. Identify Workspace Diaglog: Enter a Workspace Name and Workspace Description. Then, click on the Next button move forward in the workflow.

Oracle11gAPEX_04

  1. Create Workspace Dialog: You create a workspace, APEX presumes you want to create a new schema. That’s why the Re-use existing schema drop down chooses No by default. You enter the Schema Name as STUDENT, the Password for the STUDENT schema, and an initial Space Quota (MB) of 100. Then, click the Next button to continue.

Oracle11gAPEX_05

  1. Identify Schema Dialog: If the schema you chose exists, you get the correction dialog. You need to change the Re-use existing schema drop down from No to Yes. Then, click the Next button to continue.

Oracle11gAPEX_06

  1. Identify Administrator Dialog: Here you enter an Administrator Username, Password, First Name, Last Name, and email address. Then, click the Next button to continue.

Oracle11gAPEX_07

  1. Confirm Request Dialog: Here you review your entries and click the Confirm Request button to continue.

Oracle11gAPEX_08

  1. Success Confirmation Dialog: Here you click the Done Request button to continue.

As always, I hope this helps you learn how to create a workspace.

Written by maclochlainn

April 5th, 2015 at 1:38 am