Thursday, April 22, 2010

Advantages of Oracle PL/SQL

PL/SQL is a completely portable, high-performance transaction processing language that offers the following advantages:


 
  • support for SQL
  • support for object-oriented programming
  • better performance
  • higher productivity
  • full portability
  • tight integration with Oracle
  • security
  • Block Structure
  • Error Handling

 

 
Support for SQL

 
SQL has become the standard database language because it is flexible, powerful, and easy to learn. A few English-like commands such as SELECT, INSERT, UPDATE, and DELETE make it easy to manipulate the data stored in a relational database.

 

 

 
SQL is non-procedural, meaning that you can state what you want done without stating how to do it. Oracle determines the best way to carry out your request. There is no necessary connection between consecutive statements because Oracle executes SQL statements one at a time.

 

 

 
PL/SQL lets you use all the SQL data manipulation, cursor control, and transaction control commands, as well as all the SQL functions, operators, and pseudocolumns. So, you can manipulate Oracle data flexibly and safely. Also, PL/SQL fully supports SQL datatypes. That reduces the need to convert data passed between your applications and the database.

 

 

 
PL/SQL also supports dynamic SQL, an advanced programming technique that makes your applications more flexible and versatile. Your programs can build and process SQL data definition, data control, and session control statements "on the fly" at run time.

 

 

 
Support for Object-Oriented Programming

 
Object types are an ideal object-oriented modeling tool, which you can use to reduce the cost and time required to build complex applications. Besides allowing you to create software components that are modular, maintainable, and reusable, object types allow different teams of programmers to develop software components concurrently.

 

 

 
By encapsulating operations with data, object types let you move data-maintenance code out of SQL scripts and PL/SQL blocks into methods. Also, object types hide implementation details, so that you can change the details without affecting client programs.

 

 

 
In addition, object types allow for realistic data modeling. Complex real-world entities and relationships map directly into object types. That helps your programs better reflect the world they are trying to simulate.

 

 

 
Better Performance

 
Without PL/SQL, Oracle must process SQL statements one at a time. Each SQL statement results in another call to Oracle and higher performance overhead. In a networked environment, the overhead can become significant. Every time a SQL statement is issued, it must be sent over the network, creating more traffic.

 

 

 
However, with PL/SQL, an entire block of statements can be sent to Oracle at one time. This can drastically reduce communication between your application and Oracle. As Figure 1-5 shows, if your application is database intensive, you can use PL/SQL blocks and subprograms to group SQL statements before sending them to Oracle for execution.

 

 

 
PL/SQL stored procedures are compiled once and stored in executable form, so procedure calls are quick and efficient. Also, stored procedures, which execute in the server, can be invoked over slow network connections with a single call. That reduces network traffic and improves round-trip response times. Executable code is automatically cached and shared among users. That lowers memory requirements and invocation overhead.

 

 
PL/SQL also improves performance by adding procedural processing power to Oracle tools. Using PL/SQL, a tool can do any computation quickly and efficiently without calling on the Oracle server. This saves time and reduces network traffic.

 

 

 
Higher Productivity

 
PL/SQL adds functionality to non-procedural tools such as Oracle Forms and Oracle Reports. With PL/SQL in these tools, you can use familiar procedural constructs to build applications. For example, you can use an entire PL/SQL block in an Oracle Forms trigger. You need not use multiple trigger steps, macros, or user exits. Thus, PL/SQL increases productivity by putting better tools in your hands.

 

 

 
Moreover, PL/SQL is the same in all environments. As soon as you master PL/SQL with one Oracle tool, you can transfer your knowledge to other tools, and so multiply the productivity gains. For example, scripts written with one tool can be used by other tools.

 

 

 
Full Portability

 
Applications written in PL/SQL are portable to any operating system and platform on which Oracle runs. In other words, PL/SQL programs can run anywhere Oracle can run; you need not tailor them to each new environment. That means you can write portable program libraries, which can be reused in different environments.

 

 

 
Tight Integration with SQL

 
The PL/SQL and SQL languages are tightly integrated. PL/SQL supports all the SQL datatypes and the non-value NULL. That allows you manipulate Oracle data easily and efficiently. It also helps you to write high-performance code.

 

 

 
The %TYPE and %ROWTYPE attributes further integrate PL/SQL with SQL. For example, you can use the %TYPE attribute to declare variables, basing the declarations on the definitions of database columns. If a definition changes, the variable declaration changes accordingly the next time you compile or run your program. The new definition takes effect without any effort on your part. This provides data independence, reduces maintenance costs, and allows programs to adapt as the database changes to meet new business needs.

 

 

 
Security

 
PL/SQL stored procedures enable you to partition application logic between the client and server. That way, you can prevent client applications from manipulating sensitive Oracle data. Database triggers written in PL/SQL can disable application updates selectively and do content-based auditing of user queries.

 

 

 
Furthermore, you can restrict access to Oracle data by allowing users to manipulate it only through stored procedures that execute with their definer's privileges. For example, you can grant users access to a procedure that updates a table, but not grant them access to the table itself.

 
Block Structures
 
PL SQL consists of blocks of code, which can be nested within each other. Each block forms a unit of a task or a logical module. PL/SQL Blocks can be stored in the database and reused.



Error Handling

 PL/SQL handles errors or exceptions effectively during the execution of a PL/SQL program. Once an exception is caught, specific actions can be taken depending upon the type of the exception or it can be displayed to the user with a message.



 

Oracle PL/SQL Interview Questions-5

what is difference b/w pravite procedures and public procedures?


How to export the table data (this table having 18 million records) to .csv file. Please tell me is there any faster way to export the data.

How to get employee name from employee table which is the fiveth highest salary of the table

need to split a string into seperate values. eg. col1 col2 ---------- 100 - 'a,b,c' 200 - 'a,x,b,d,e' 300 - 'c' result: value count ------------- a - 2 b - 1 c - 2 etc.

How many levels can subqueries be nested in a FROM clause?

using comand prompt how can import table data and table space with example

how can create data base link for tow servers (scott schema) give examples plz

if a table is getting updated what happens if a function is called from sql query?

There is a sequence with min value 100. I want to alter this sequence to min value as 101. If the table has already data in the sequence column as 100,101,102... Is it possible to do so ?

Write a query to find five highest salaries from EMP table. (there is a column SALARY)

what is the difference between cursor FETCH and FOR LOOP ?

what will be the output: select 1 from emp union all select 2 from emp;

Write a query to find the name of employees those who have joined on Monday.(based on column hire_date)

i have a table eno dno sal 1 10 200 2 10 150 3 10 100 4 20 75 5 20 100 i want to get sal which is less than the avg sal of thri dept. eno dno sal 2 10 150 3 10 100 4 20 75

write a query to find out the no. of employees whose age is less than 25 and max of salary for the employees belonging to a particular department is less than 20000

What is mutating trigger?How to avoid it??

can we delete the trigger in a view? if yes why if not why?

what is the difference between implicit and explicit trigger

how to sort records in sql?

can we call a procedure from a function?

Wednesday, April 21, 2010

Oracle PL/SQL Interview Questions-4

What is SQL Integrity?

How packaged procedures and functions are called from the following? a. Stored procedure or anonymous block b. an application program such a PRC *C, PRO* COBOL c. SQL *PLUS

What is SQL Deadlock?

Give the structure of the procedure ?

What is Mutating SQL Table?

What are the return values of functions SQLCODE and SQLERRM ?

The most important DDL statements in SQL are?

Operators used in SELECT statements are?

SELECT statements in SQL?

What are the PL/SQL Statements used in cursor processing ?

The SELECT INTO Statement is most often used to create backup copies of tables or for archiving records?

The Update Statement in SQL.

What is the Delete Statements in SQL?

How to sort the rows in SQL?

The IN operator may be used if you know the exact value you want to return for at least one of the columns.

how to create table with in the procedure or function?

what is overloading procedure or overloading function ?

what is HASH join?

what is SCALAR Queries?

what is the use of HASH, LIST partitions?

<> declare a=10 b=20, begin some statements declare a=30 c=40 end; what is the A value in nested block?
 
cursor types? explain with example programs?

                                                     Next>>

Oracle PL/SQL Interview Questions-3

What is an Exception ? What are types of Exception ?

What are the datatypes a available in PL/SQL ?

The INSERT INTO Statements in SQL?

What are the components of a PL/SQL block ?

What is SQL*Loader?

What is PL/SQL table ?

What are the components of a PL/SQL Block ?

What is a JOIN?

What is Consistency?

What is Indexes?

Give the structure of the function ?

What is a cursor ? Why Cursor is required ?

What is the use of CASCADE CONSTRAINTS?

What is Date Functions?

What is COLUMN?

What is COMPUTE?

What is Commit?

What is TTITLE and BTITLE?

What is SET?

What is Union?

What is Minus?

What is Correlated Subquery?

What is Multiple columns?

What is Sequences?

What is Synonyms?

What is Data types?

What is Transaction?

What is Posting?

What is Savepoint?

What is Set Transaction?

What is Locking?
                         
                                        Next>>

Oracle PL/SQL Interview Questions-2

What are % TYPE and % ROWTYPE ? What are the advantages of using these over datatypes?

How we can create a table through procedure ?

Explain the two type of Cursors ?

What is difference between a Cursor declared in a procedure and Cursor declared in a package
specification ?

How to disable multiple triggers of a table at at a time?

How to avoid using cursors? What to use instead of cursor and in what cases to do so?

What is Overloading of procedures ?

Can we declare a column having number data type and its scale is larger than pricesion ex: column_name NUMBER(10,100), column_name NUMBAER(10,-84)

What happens if a procedure that updates a column of table X is called in a database trigger of the same table ?

What is NVL?

What are the two parts of a procedure ?

Write the order of precedence for validation of a column in a table ? I. done using Database triggers. ii. done using Integarity Constraints.

What is Character Functions?

What is Rollback?

What are the cursor attributes used in PL/SQL ?


In a Distributed Database System Can we execute two queries simultaneously ? Justify ?

In pl/sql functions what is use of out parameter even though we have return statement.

What are advantages fo Stored Procedures

What is SPOOL?

What is Intersect?

                                    Next>>