Pages

How to Run Script in SQL Plus and Save the Output

There are several Oracle SQL*Plus questions often asked. How to run a SQL script in Oracle SQLPlus? How to execute a script file within SQL Plus environment? How to save the script output in SQLPlus to a text file?

In Oracle, use @ to run a script file after starting SQL Plus. SQL Plus can be started from any directory where the user is given the access to. The user account needs privilege to run sqlplus which is usually in the $ORACLE_HOME/bin folder. The following is the format to run a script in SQL Plus in the Linux environment:

SQL > @script.sql
SQL > @/path/script.sql

If the path is not specified, SQL Plus look for the script file in the directory where the current user account is at. You can use cd to change the directory to the location where the script is put, and then run SQL Plus. Otherwise, you can specify the path of the script in the @ command.

Examples

We need to run “DGPhyStby_script_v3.sql” which is provided by Oracle for Data Guard diagnostics. First, we download the script and upload it to our Oracle server (Linux) in the /oracle_staging directory. Then we start SQL Plus and run the script by its name.

In the first example, we change the path to /oracle_staging and then run SQL Plus and execute the script directly in SQL Plus environment.  In the second example, we start SQL Plus and execute the script by giving both path and file name.

[oracle@drodbp01 ~]$ cd /oracle_staging
[oracle@drodbp01 oracle_staging]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Apr 10 13:07:50 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options
SQL> @DGPhyStby_script_v3.sql


[oracle@hqodbp01 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Apr 10 13:19:41 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL> @/oracle_staging/DGPhyStby_script_v3.sql


Save SQL*Plus Output to a File

To save the output, use spool filename to start saving the output, and use spool off to end the end the saving. Let’s take a look of “DGPhyStby_script_v3.sql” script. The beginning of the script contains the following lines to prepare the output file to be saved:

set echo off
set feedback off
column timecol new_value timestamp
column spool_extension new_value suffix
SELECT TO_CHAR(sysdate,'mmddyyyy_hh24miss') timecol, '.html' spool_extension FROM dual;
column output new_value dbname
SELECT value || '_' output FROM v$parameter WHERE name = 'db_unique_name';
spool dg_psbydiag_&&dbname&&timestamp&&suffix

The output file name is constructed by several parameters. The saved file is like:
dg_psbydiag_drcdbsblp_04102018_130935.html

The script has the following last lines to end the spooling of the output:

spool off
set markup html off entmap on


To investigate the whole script, click here: https://cl.ly/qmhw

The Contingency Leadership

A leadership approach in applying power and influence depends on the leader’s style adapted to fit the situation.  According to contingency leadership theory, no single best leadership style can be identified because the effectiveness of leadership is contingent to the situation.  As stated in Larsson and Vinberg (2010), successful leadership behavior includes “both universal and contingency elements” (p. 329), and the influence of situation is an important variable.

Facing Challenge of Rapid Business Growth: Getting Help from I/O Psychologists

The rapid growth of a business reveals success of leadership. While rapid growth of a corporation brings good news to shareholders, it also places challenges to executive managers.  The expansion of business may push the current operational capacity to its limit in both facilities and the workforce.  In this situation, managers and field workers would experience overwhelming pressures with straitened schedules and increased workloads, that could worsen work conditions, decrease work ethic, and break a favorable corporate culture.  If this problem is not addressed, they will negatively affect product quality and customer service, and eventually hurt the company’s bottom line.

Business growth brings both opportunities and risks. In order to control risks of rapid growth, the management team often implements various strategies to improve operational workflow.  One commonly used strategy is to expand the workforce by adding new jobs.  Adding new positions in key business areas can often facilitate business expansion and alleviate potential risks in production and services. The task of selecting and hiring new workers is always challenging due to multiple dimensions and metrics involved in the process and outcome.

Job Analysis for Qualifications of New Positions

Due to dynamics of today’s business, many rapid-growth companies need to create new positions to handle ever-changing demands in management, marketing, and technology.  These new positions often require greater level of integration and diversification in job functions.  For example, a new position of social media manager may require job functions across multiple departments of marketing, sales, public relations (PR), research and development (R&D), and information technology (IT).  An employee on this position must demonstrate integrated skills and knowledge not only in management, but also in internet marketing, social networking, web technology, and social psychology as well.  This phenomenon will certainly challenge I/O psychologists in job analysis and determination of required qualifications for the new jobs.  The purpose of job analyses is to recognize all tasks required to perform the job and the conditions necessary for the tasks to be executed.  Job analysis also identifies qualifications including knowledge, skills, abilities, and other characteristics (KSAOs) needed for performing the tasks under the given conditions.

The Transformational Leadership

Transformational leadership is the process to “develop and promote values and goals that are shared by both leaders and followers” (Haslam, Reicher, & Platow, 2010, p. 251).  The transformational leadership requires a leader’s ability to inspiring and motivating followers to act on the basis of shared value and vision. In the transformational approach, the leadership success depends on a leader’s ability to encourage followers to rise above low-level transactional considerations and instead pursue a higher-order sense of morality and purpose (Haslam, Reicher, & Platow, 2010, p. 251).  According to Caldwell, Dixon, Floyd, Chaudoin, Post, and Cheokas (2012), the transformational leadership approach gives leaders the mechanism to transform organizational goals into synergistic duties of the individuals.  Caldwell et al. (2012) specified four components of the transformational leadership, which are “idealized influence, inspirational motivation, intellectual stimulation, and individualized consideration” (p. 177).  With each of the four components, workers are inspired to take efforts for their own personal development while also improving the performance of the organization.

Performance Appraisal and Job Assessment

Performance appraisal as a common human resource management tool is “an evaluative process involving the assessment of employee performance in light of predetermined standards” (Smither as cited in Mitchell, 2010, p. 82).  To ensure continuous success of the employee on the new job, a performance appraisal should be conducted to provide the worker and the organization with “the systematic review and evaluation of job performance, as well as the provision of performance feedback” (Levy, 2010, p. 105).

Roles and Expectations of Organizational Leadership

Leadership is regarded as a social influence of initiation and guidance for organizational operation and change.  Surugiu and Surugiu (2012) stated that leadership is seen as a “social process of exchange in which the leader gives something to those who follow him” (p. 303). This process has three variables: the leader, the followers and the situation.  Leaders envision the future of the organization to develop and implement business strategies and set the strategic direction of the organization.  The most important responsibilities of the leaders are duties related to the achievement of objectives that interested subordinates, and in the same time, improved the organizations’ development. Thus, an effective leader “correlates subordinate’s objectives to the objectives of the organization” (Surugiu & Surugiu, 2012, p. 305).

The Charismatic Leadership

Charismatic leadership is the capacity to influence group members to contribute to group goals that is seen to derive from the distinctive charismatic qualities of a leader (Haslam, Reicher, & Platow, 2010).  In charismatic leadership, a leader uses charisma or charismatic power rather than position power to attract and influence followers.  Leader charisma has been defined as “the ability of a leader to exercise diffuse and intense influence over the beliefs, values, behavior, and performance of others through their own behavior, beliefs, and personal example” (House, Spangler, & Woycke as cited in Kwak, 2012, p. 56).  The key to charismatic leadership success is to attract and maintain loyal followers because “charismatic leaders need followers that believe and trust in them and their mission” (Sandberg & Moreman, 2011, p. 240).  As noted in Hayibor, Agle, Sears, Sonnenfeld, and Ward (2011), a charismatic leader must be capable to recognize subordinates’ values and to appeal to these values in communications with followers in order to develop a perception of trust.

Organizational Crises: How to Detect, intervene, and Prevent

Crises occur in a group or organization in many forms such as natural disasters, fatal accidents, workplace violence, financial turmoil, and so forth.  A crisis is “a low-probability, high-impact event that threatens the viability of the organization and is characterized by ambiguity of cause, effect, and means of resolution, as well as by a belief that decisions must be made swiftly” (Lussier & Achua, 2010, p. 456). An organization’s long-term sustainability and success depend on its effective leadership to managing and overcoming crisis.   It is crucial for the leadership team to be prepared to respond to and deal with crisis in an organization.

A Tale Of Two Start-Ups

The importance of selling during the start-up stage of business was exemplified some years ago by a profile of two entrepreneurs in Success Magazine.

One, a New York realtor, wanted to broker surplus office space through the Internet. He spent a year and most of $10,000 he had saved to build an impressive website. He told the magazine that he believed his site would be so good that it would make him “the next Jeff Bezos.”