Sunteți pe pagina 1din 5

In Unix there are several shells that can be used, the C shell ( csh and its extension, the

T C shell tcsh), the Bourne Shell (sh and its extensions the Bourne Again Shell bash and the highly programmable Korn shell ksh ) being the more commonly used. There are two ways to invoke a shell script file. 2.1 Direct Interpretation In direct interpretation, the command csh filename [arg ...] invokes the program csh to interpret the script contained in the file `filename'. 2.2 Indirect Interpretation In indirect interpretation, we must insert as the first line of the file #! /bin/csh awk myscript.sh In the above example this command would execute the awk script "myscript.sh". BC Calculator. 1+2 quit Analytic Functions, which have been available since Oracle 8.1.6, are designed to address such problems as "Calculate a running total", "Find percentages within a group", "Top-N queries", "Compute a moving average" and many more. Most of these problems can be solved using standard PL/SQL, however the performance is often not what it should be. Analytic Functions add extensions to the SQL language that not only make these operations easier to code; they make them faster than could be achieved with pure SQL or PL/SQL. These extensions are currently under review by the ANSI SQL committee for inclusion in the SQL specification. How Analytic Functions Work ? Analytic functions compute an aggregate value based on a group of rows. They differ from aggregate functions in that they return multiple rows for each group. The group of rows is called a window and is defined by the analytic clause. For each row, a "sliding" window of rows is defined. The window determines the range of rows used to perform the calculations for the "current row". Window sizes can be based on either a physical number of rows or a logical interval such as time. Analytic functions are the last set of operations performed in a query except for the final ORDER BY clause. All joins and all WHERE, GROUP BY, and HAVING clauses are completed before the analytic functions are processed. Therefore, analytic functions can appear only in the select list or ORDER BY clause. SUM(sal) OVER (ORDER BY deptno, ename) ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ENAME) The DENSE_RANK function computes the rank of a row in an ordered group of rows. The ranks are consecutive integers beginning with 1. The largest rank value is the number of unique values returned by the query. Rank values are not skipped in the event of ties.

Business intelligence systems need to perform complex queries efficiently, and some of these queries must access hierarchical data. For example, an employee table may hold an organization's hierarchy information by listing each employee's name and manager. How can we generate an organization chart based on the hierarchical data? Oracle9i can readily perform the necessary hierarchical query with the CONNECT BY clause. The CONNECT BY clause specifies the relationship between parent rows and child rows in the hierarchy and the starting point of the hierarchy. Here is a simple example of a hierarchical query: SELECT employee_name, manager_name, LEVEL FROM employees START WITH employee_name = 'King' CONNECT BY PRIOR employee_id = manager_id; This query returns rows from the table employees in a hierarchical order starting with the employee whose name is 'King.' The LEVEL keyword is used to show the level of the hierarchy. A partial set of results is shown below: EMPLOYEE_NAME King Greenberg Faviet Chen Sciarra Urman MANAGER_NAME King Greenberg Greenberg Greenberg Greenberg LEVEL 1 2 3 3 3 3

A workflow is a set of instructions that tells the PowerCenter Server how to execute tasks such as sessions, email notifications, and shell commands. After you create tasks in the Task Developer and Workflow Designer, you connect the tasks with links to create a workflow. In the Workflow Designer, you can specify conditional links and use workflow variables to create branches in the workflow. The Workflow Manager also provides Event-Wait and Event-Raise tasks so you can control the sequence of task execution in the workflow. You can also create worklets and nest them inside the workflow. Every workflow contains a Start task, which represents the beginning of the workflow

A worklet is an object that represents a set of tasks. It can contain any task available in the Workflow Manager. You can run worklets inside a workflow. The workflow that contains the worklet is called the parent workflow. You can also nest a worklet in another worklet. Create a worklet when you want to reuse a set of workflow logic in several workflows. Use the Worklet Designer to create and edit worklets. When the PowerCenter Server runs a worklet, it expands the worklet. The PowerCenter Server then runs the worklet as it would any other workflow, executing tasks and evaluating links in the worklet. The worklet does not contain any scheduling or server information. To run a worklet, include the worklet in a workflow. The worklet runs on the PowerCenter

Server you choose for the workflow. The Workflow Manager does not provide a parameter file or log file for worklets. The PowerCenter Server writes information about worklet execution in the workflow log.

Error redirect ls -l z* 2> /dev/null This command tells your Bourne shell that if any errors do occur, redirect the error so that it is sent to "/dev/null". This device (/dev/null) is often referred to as the "bit bucket", because any time a user is getting output that they don't want, they send it here. It's like a garbage can for your unwanted bits.

To mail a file to joan, use < filename-to tell the shell to attach the file, instead of your keyboard, to mail's standard input: % mail joan < myfile Stop Background Output with stty tostop $# - a shell variable which is set when a script is invoked. It carries the number of arguments or passed parameters that were on the command line when it was executed.

tr -cd '\11\12\40-\176' < myfile1 > myfile2 - this example would take the file myfile1 and strip all non printable characters and take that results to myfile2.

This transfer of control between the PL/SQL and SQL engines is called a context switch. Each time a switch occurs, there is additional overhead. There are a number of scenarios in which many switches occur and performance degrades. Oracle 8.1 now offers two enhancements to PL/SQL that allow you to bulk together multiple context switches into a single switch, thereby improving the performance of your applications. These new features are as follows: FORALL - A variation on the FOR loop that bundles together multiple DML statements based on data in a collection BULK COLLECT - An enhancement to implicit and explicit query cursor syntax that allows the transfer of multiple rows of data in a single round-trip between the PL/SQL and SQL engines FORALL. FORALL tells the PL/SQL runtime engine to bulk bind into the SQL statement all the elements of one or more collections before sending anything to the SQL engine. The body of the FORALL statement is a single DML statementan INSERT, UPDATE, or DELETE. The DML must reference collection elements, indexed by the index_row variable in the FORALL statement. The scope of the index_row variable is the FORALL statement only; you may not reference it outside of that statement. cur%FOUND Returns TRUE if the last FETCH found a row cur%NOTFOUND Returns FALSE if the last FETCH found a row cur%ISOPEN Returns TRUE if the specified cursor is open. cur%ROWCOUNT Returns the number of rows modified by the DML statement SQL%BULK_ROWCOUNT Returns the number of rows processed for each execution of the bulk DML operation

Collection Oracle introduced the TABLE datatype as a way of storing singly dimensioned sparse arrays in PL/SQL. PL/SQL8 introduces two new collection structures that have a wide range of new uses. These structures are nested tables and variable-size arrays (VARRAYs). Like PL/SQL tables, these structures can also be used in PL/SQL programs. But what is new is the ability to use the new collections as the datatypes of fields in conventional tables and attributes of objects.

Packages A package is a collection of PL/SQL objects that are grouped together. There are a number of benefits to using packages, including information hiding, object-oriented design, top-down design, object persistence across transactions, and improved performance. Elements that can be placed in a package include procedures, functions, constants, variables, cursors, exception names, and TYPE statements (for index-by tables, records, REF CURSORs, etc.). 1.14.1 Overview of Package Structure A package can have two parts: the specification and the body. The package specification is required and lists all the objects that are publicly available (may be referenced from outside the package) for use in applications. It also provides all the information a developer needs in order to use objects in the package; essentially, it is the package's API. The package body contains all code needed to implement procedures, functions, and cursors listed in the specification, as well as any private objects (accessible only to other elements defined in that package), and an optional initialization section. If a package specification does not contain any procedures or functions and no private code is needed, then that package does not need to have a package body. The syntax for the package specification is: CREATE [OR REPLACE] PACKAGE package_name [ AUTHID CURRENT_USER | DEFINER ] -- Oracle8i IS | AS [definitions of public TYPEs ,declarations of public variables, types and objects ,declarations of exceptions ,pragmas ,declarations of cursors, procedures and functions ,headers of procedures and functions] END [package_name]; The syntax for the package body is: CREATE [OR REPLACE] PACKAGE BODY package_name IS | AS [definitions of private TYPEs ,declarations of private variables, types and objects ,full definitions of cursors ,full definitions of procedures and functions] [BEGIN executable_statements [EXCEPTION exception_handlers ] ] END [package_name]; The optional OR REPLACE keywords are used to rebuild an existing package, preserving its privileges. The declarations in the specifications cannot be repeated in the body. Both the executable section and the exception section are

optional in a package body. If the executable section is present, it is called the initialization section and executes only once -- the first time any package element is referenced during a session. You must compile the package specification before the body specification. When you grant EXECUTE authority on a package to another schema or to PUBLIC, you are giving access only to the specification; the body remains hidden. Here's an example of a package: CREATE OR REPLACE PACKAGE time_pkg IS FUNCTION GetTimestamp RETURN DATE; PRAGMA RESTRICT_REFERENCES (GetTimestamp, WNDS); PROCEDURE ResetTimestamp; END time_pkg; CREATE OR REPLACE PACKAGE BODY time_pkg IS StartTimeStamp DATE := SYSDATE; -- StartTimeStamp is package data. FUNCTION GetTimestamp RETURN DATE IS BEGIN RETURN StartTimeStamp; END GetTimestamp; PROCEDURE ResetTimestamp IS BEGIN StartTimeStamp := SYSDATE; END ResetTimestamp; END time_pkg; 1.14.2 Referencing Package Elements The elements declared in the specification are referenced from the calling application via dot notation: package_name.package_element PL/SQL provides the following statements for transaction management: COMMIT -- Saves all outstanding changes since the last COMMIT or ROLLBACK and releases all locks. ROLLBACK -- Erases all outstanding changes since the last COMMIT or ROLLBACK and releases all locks. ROLLBACK TO SAVEPOINT erases all changes made since the specified savepoint was established. SAVEPOINT -- Establishes a savepoint, which then allows you to perform partial ROLLBACKs. SET TRANSACTION -- Allows you to begin a read-only or read-write session, establish an isolation level, or assign the current transaction to a specified rollback segment. Procedure A PL/SQL procedure is a stand alone program that is compiled into an Oracle database schema. Procedures can accept arguments. You can execute a PL/SQL procedure from a SQL*Plus session or from any interface that can execute SQL statements. When this procedure is compiled, the procedure identifier of the CREATE PROCEDURE statement, becomes an object name in the data dictionary; the object type is PROCEDURE. A procedure has three parts: Declarative Part Subprogram Body Exception Handler A function without a RETURN statement will compile with errors

S-ar putea să vă placă și