Anda di halaman 1dari 67

Index Search Add FAQ Ask Question

Oracle PL/SQL FAQ


$Date: 17-Dec-2001 $
$Revision: 2.05 $
$Author: Frank Naud $

Topics

What is PL/SQL and what is it used for?


Should one use PL/SQL or Java to code procedures and triggers?
How can one see if somebody modified any code?
How can one search PL/SQL code for a string/key value?
How can one keep a history of PL/SQL code changes?
How can I protect my PL/SQL source code?
Can one print to the screen from PL/SQL?
Can one read/write files from PL/SQL?
Can one call DDL statements from PL/SQL?
Can one use dynamic SQL statements from PL/SQL?
What is the difference between %TYPE and %ROWTYPE?
What is the result of comparing NULL with NULL?
How does one get the value of a sequence into a PL/SQL variable?
Can one execute an operating system command from PL/SQL?
How does one loop through tables in PL/SQL?
How often should one COMMIT in a PL/SQL loop? / What is the best commit strategy?
I can SELECT from SQL*Plus but not from PL/SQL. What is wrong?
What is a mutating and constraining table?
Can one pass an object/table as an argument to a remote procedure?
Is it better to put code in triggers or procedures? What is the difference?
Is there a PL/SQL Engine in SQL*Plus?
Is there a limit on the size of a PL/SQL block?
Where can one find more info about PL/SQL?

Back to Oracle FAQ Index

What is PL/SQL and what is it used for?


PL/SQL is Oracle's Procedural Language extension to SQL. PL/SQL's language syntax, structure and data types
are similar to that of ADA. The PL/SQL language includes object oriented programming techniques such as
encapsulation, function overloading, information hiding (all but inheritance). PL/SQL is commonly used to write
data-centric programs to manipulate data in an Oracle database.
Back to top of file

Should one use PL/SQL or Java to code procedures and triggers?


Internally the Oracle database supports two procedural languages, namely PL/SQL and Java. This leads to questions
like "Which of the two is the best?" and "Will Oracle ever desupport PL/SQL in favour of Java?".
Many Oracle applications are based on PL/SQL and it would be difficult of Oracle to ever desupport PL/SQL. In
fact, all indications are that PL/SQL still has a bright future ahead of it. Many enhancements are still being made to
PL/SQL. For example, Oracle 9iDB supports native compilation of Pl/SQL code to binaries.
PL/SQL and Java appeal to different people in different job roles. The following table briefly describes the
difference between these two language environments:
PL/SQL:
Data centric and tightly integrated into the database Proprietary to Oracle and difficult to port to other database
systems Data manipulation is slightly faster in PL/SQL than in Java Easier to use than Java (depending on your
background)
Java:
Open standard, not proprietary to Oracle Incurs some data conversion overhead between the Database and Java type
systems Java is more difficult to use (depending on your background)
Back to top of file

How can one see if somebody modified any code?


Code for stored procedures, functions and packages is stored in the Oracle Data Dictionary. One can detect code
changes by looking at the LAST_DDL_TIME column in the USER_OBJECTS dictionary view. Example:
SELECT OBJECT_NAME,
TO_CHAR(CREATED,
'DD-Mon-RR HH24:MI') CREATE_TIME,
TO_CHAR(LAST_DDL_TIME, 'DD-Mon-RR HH24:MI') MOD_TIME,
STATUS
FROM
USER_OBJECTS
WHERE LAST_DDL_TIME > '&CHECK_FROM_DATE';
Back to top of file

How can one search PL/SQL code for a string/ key value?
The following query is handy if you want to know where a certain table, field or expression is referenced in your
PL/SQL source code.
SELECT TYPE, NAME, LINE
FROM
USER_SOURCE
WHERE UPPER(TEXT) LIKE '%&KEYWORD%';
Back to top of file

How can one keep a history of PL/SQL code changes?


One can build a history of PL/SQL code changes by setting up an AFTER CREATE schema (or database) level
trigger (available from Oracle 8.1.7). This way one can easily revert to previous code should someone make any
catastrophic changes. Look at this example:
CREATE TABLE SOURCE_HIST
-- Create history table
AS SELECT SYSDATE CHANGE_DATE, USER_SOURCE.*
FROM
USER_SOURCE WHERE 1=2;
table

CREATE OR REPLACE TRIGGER change_hist

-- Store code in hist

AFTER CREATE ON SCOTT.SCHEMA


-- Change SCOTT to your
schema name
DECLARE
BEGIN
if DICTIONARY_OBJ_TYPE in ('PROCEDURE', 'FUNCTION',
'PACKAGE', 'PACKAGE BODY', 'TYPE') then
-- Store old code in SOURCE_HIST table
INSERT INTO SOURCE_HIST
SELECT sysdate, user_source.* FROM USER_SOURCE
WHERE TYPE = DICTIONARY_OBJ_TYPE
AND NAME = DICTIONARY_OBJ_NAME;
end if;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20000, SQLERRM);
END;
/
show errors
Back to top of file

How can I protect my PL/SQL source code?


PL/SQL V2.2, available with Oracle7.2, implements a binary wrapper for PL/SQL programs to protect the source
code.
This is done via a standalone utility that transforms the PL/SQL source code into portable binary object code
(somewhat larger than the original). This way you can distribute software without having to worry about exposing
your proprietary algorithms and methods. SQL*Plus and SQL*DBA will still understand and know how to execute
such scripts. Just be careful, there is no "decode" command available.
The syntax is:
wrap iname=myscript.sql oname=xxxx.plb
Back to top of file

Can one print to the screen from PL/SQL?


One can use the DBMS_OUTPUT package to write information to an output buffer. This buffer can be displayed on
the screen from SQL*Plus if you issue the SET SERVEROUTPUT ON; command. For example:
set serveroutput on
begin
dbms_output.put_line('Look Ma, I can print from PL/SQL!!!');
end;
/
DBMS_OUTPUT is useful for debugging PL/SQL programs. However, if you print too much, the output buffer will
overflow. In that case, set the buffer size to a larger value, eg.: set serveroutput on size 200000

If you forget to set serveroutput on type SET SERVEROUTPUT ON once you remember, and then EXEC NULL;. If
you haven't cleared the DBMS_OUTPUT buffer with the disable or enable procedure, SQL*Plus will display the
entire contents of the buffer when it executes this dummy PL/SQL block.
Back to top of file

Can one read/write files from PL/SQL?


Included in Oracle 7.3 is an UTL_FILE package that can read and write operating system files. The directory you
intend writing to has to be in your INIT.ORA file (see UTL_FILE_DIR=... parameter). Before Oracle 7.3 the only
means of writing a file was to use DBMS_OUTPUT with the SQL*Plus SPOOL command.
Copy this example to get started:
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('/tmp', 'myfile', 'w');
UTL_FILE.PUTF(fileHandler, 'Look ma, I''m writing to a file!!!\n');
UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
WHEN utl_file.invalid_path THEN
raise_application_error(-20000, 'ERROR: Invalid path for file or
path not in INIT.ORA.');
END;
/
Back to top of file

Can one call DDL statements from PL/SQL?


One can call DDL statements like CREATE, DROP, TRUNCATE, etc. from PL/SQL by using the "EXECUTE
IMMEDATE" statement. Users running Oracle versions below 8i can look at the DBMS_SQL package (see FAQ
about Dynamic SQL).
begin
EXECUTE IMMEDIATE 'CREATE TABLE X(A DATE)';
end;
NOTE: The DDL statement in quotes should not be terminated with a semicolon.
Back to top of file

Can one use dynamic SQL statements from PL/SQL?


Starting from Oracle8i one can use the "EXECUTE IMMEDIATE" statement to execute dynamic SQL and PL/SQL
statements (statements created at run-time). Look at these examples. Note that statements are NOT terminated by
semicolons:
EXECUTE IMMEDIATE 'CREATE TABLE x (a NUMBER)';
-- Using bind variables...
sql_stmt := 'INSERT INTO dept VALUES (:1, :2, :3)';
EXECUTE IMMEDIATE sql_stmt USING dept_id, dept_name, location;
-- Returning a cursor...
sql_stmt := 'SELECT * FROM emp WHERE empno = :id';
EXECUTE IMMEDIATE sql_stmt INTO emp_rec USING emp_id;
One can also use the older DBMS_SQL package (V2.1 and above) to execute dynamic statements. Look at these
examples:

CREATE OR REPLACE PROCEDURE DYNSQL AS


cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur, 'CREATE TABLE X (Y DATE)', DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;
/
More complex DBMS_SQL example using bind variables:
CREATE OR REPLACE PROCEDURE DEPARTMENTS(NO IN DEPT.DEPTNO%TYPE) AS
v_cursor integer;
v_dname char(20);
v_rows
integer;
BEGIN
v_cursor := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(v_cursor, 'select dname from dept where deptno > :x',
DBMS_SQL.V7);
DBMS_SQL.BIND_VARIABLE(v_cursor, ':x', no);
DBMS_SQL.DEFINE_COLUMN_CHAR(v_cursor, 1, v_dname, 20);
v_rows := DBMS_SQL.EXECUTE(v_cursor);
loop
if DBMS_SQL.FETCH_ROWS(v_cursor) = 0 then
exit;
end if;
DBMS_SQL.COLUMN_VALUE_CHAR(v_cursor, 1, v_dname);
DBMS_OUTPUT.PUT_LINE('Deptartment name: '||v_dname);
end loop;
DBMS_SQL.CLOSE_CURSOR(v_cursor);
EXCEPTION
when others then
DBMS_SQL.CLOSE_CURSOR(v_cursor);
raise_application_error(-20000, 'Unknown Exception Raised: '||
sqlcode||' '||sqlerrm);
END;
/
Back to top of file

What is the difference between %TYPE and %ROWTYPE?


The %TYPE and %ROWTYPE constructs provide data independence, reduces maintenance costs, and allows
programs to adapt as the database changes to meet new business needs.
%ROWTYPE is used to declare a record with the same types as found in the specified database table, view or
cursor. Example:
DECLARE
v_EmpRecord emp%ROWTYPE;
%TYPE is used to declare a field with the same type as that of a specified table's column. Example:
DECLARE
v_EmpNo emp.empno%TYPE;
Back to top of file

What is the result of comparing NULL with NULL?


NULL is neither equal to NULL, nor it is not equal to NULL. Any comparison to NULL is evaluated to NULL.
Look at this code example to convince yourself.
declare
a number := NULL;
b number := NULL;
begin
if a=b then
dbms_output.put_line('True, NULL = NULL');
elsif a<>b then
dbms_output.put_line('False, NULL <> NULL');
else
dbms_output.put_line('Undefined NULL is neither = nor <> to
NULL');
end if;
end;
Back to top of file

How does one get the value of a sequence into a PL/SQL variable?
As you might know, one cannot use sequences directly from PL/SQL. Oracle (for some silly reason) prohibits this:
i := sq_sequence.NEXTVAL;
However, one can use embedded SQL statements to obtain sequence values:
select sq_sequence.NEXTVAL into :i from dual;
Thanks to Ronald van Woensel

Back to top of file

Can one execute an operating system command from PL/SQL?


There is no direct way to execute operating system commands from PL/SQL in Oracle7. However, one can write an
external program (using one of the precompiler languages, OCI or Perl with Oracle access modules) to act as a
listener on a database pipe (SYS.DBMS_PIPE). Your PL/SQL program then put requests to run commands in the
pipe, the listener picks it up and run the requests. Results are passed back on a different database pipe. For an Pro*C
example, see chapter 8 of the Oracle Application Developers Guide.
In Oracle8 one can call external 3GL code in a dynamically linked library (DLL or shared object). One just write a
library in C/ C++ to do whatever is required. Defining this C/C++ function to PL/SQL makes it executable. Look at
this External Procedure example.
Back to top of file

How does one loop through tables in PL/SQL?


Look at the following nested loop code example.
DECLARE
CURSOR dept_cur IS
SELECT deptno
FROM dept
ORDER BY deptno;
-- Employee cursor all employees for a dept number
CURSOR emp_cur (v_dept_no DEPT.DEPTNO%TYPE) IS
SELECT ename
FROM emp
WHERE deptno = v_dept_no;

BEGIN
FOR dept_rec IN dept_cur LOOP
dbms_output.put_line('Employees in Department '||
TO_CHAR(dept_rec.deptno));
FOR emp_rec in emp_cur(dept_rec.deptno) LOOP
dbms_output.put_line('...Employee is '||emp_rec.ename);
END LOOP;
END LOOP;
END;
/
Back to top of file

How often should one COMMIT in a PL/SQL loop? / What is the best commit
strategy?
Contrary to popular believe, one should COMMIT less frequently within a PL/SQL loop to prevent ORA-1555
(Snapshot too old) errors. The higher the frequency of commit, the sooner the extents in the rollback segments will
be cleared for new transactions, causing ORA-1555 errors.
To fix this problem one can easily rewrite code like this:
FOR records IN my_cursor LOOP
...do some stuff...
COMMIT;
END LOOP;
... to ...
FOR records IN my_cursor LOOP
...do some stuff...
i := i+1;
IF mod(i, 10000) THEN
-- Commit every 10000 records
COMMIT;
END IF;
END LOOP;
If you still get ORA-1555 errors, contact your DBA to increase the rollback segments.
NOTE: Although fetching across COMMITs work with Oracle, is not supported by the ANSI standard.
Back to top of file

I can SELECT from SQL*Plus but not from PL/SQL. What is wrong?
PL/SQL respect object privileges given directly to the user, but does not observe privileges given through roles. The
consequence is that a SQL statement can work in SQL*Plus, but will give an error in PL/SQL. Choose one of the
following solutions:
Grant direct access on the tables to your user. Do not use roles!
GRANT select ON scott.emp TO my_user;
Define your procedures with invoker rights (Oracle 8i and higher);
Move all the tables to one user/schema.
Back to top of file

What is a mutating and constraining table?


"Mutating" means "changing". A mutating table is a table that is currently being modified by an update, delete, or
insert statement. When a trigger tries to reference a table that is in state of flux (being changed), it is considered
"mutating" and raises an error since Oracle should not return data that has not yet reached its final state.

Another way this error can occur is if the trigger has statements to change the primary, foreign or unique key
columns of the table off which it fires. If you must have triggers on tables that have referential constraints, the
workaround is to enforce the referential integrity through triggers as well.
There are several restrictions in Oracle regarding triggers:
A row-level trigger cannot query or modify a mutating table. (Of course, NEW and OLD still can be
accessed by the trigger) .
A statement-level trigger cannot query or modify a mutating table if the trigger is fired as the result of a
CASCADE delete.
Etc.
Back to top of file

Can one pass an object/table as an argument to a remote procedure?


The only way the same object type can be referenced between two databases is via a database link. Note that it is not
enough to just use the same type definitions. Look at this example:
-- Database A: receives a PL/SQL table from database B
CREATE OR REPLACE PROCEDURE pcalled(TabX DBMS_SQL.VARCHAR2S) IS
BEGIN
-- do something with TabX from database B
null;
END;
/
-- Database B: sends a PL/SQL table to database A
CREATE OR REPLACE PROCEDURE pcalling IS
TabX DBMS_SQL.VARCHAR2S@DBLINK2;
BEGIN
pcalled@DBLINK2(TabX);
END;
/
Back to top of file

Is it better to put code in triggers or procedures? What is the difference?


In earlier releases of Oracle it was better to put as much code as possible in procedures rather than triggers. At that
stage procedures executed faster than triggers as triggers had to be re-compiled every time before executed (unless
cached). In more recent releases both triggers and procedures are compiled when created (stored p-code) and one
can add as much code as one likes in either procedures or triggers.
Back to top of file

Is there a PL/SQL Engine in SQL*Plus?


No. Unlike Oracle Forms, SQL*Plus does not have an embedded PL/SQL engine. Thus, all your PL/SQL code is
sent directly to the database engine for execution. This makes it much more efficient as SQL statements are not
stripped off and sent to the database individually.
Back to top of file

Is there a limit on the size of a PL/SQL block?


Yes, the max size is not an explicit byte limit, but related to the parse tree that is created when you compile the code.
You can run the following select statement to query the size of an existing package or procedure:
SQL> select * from dba_object_size where name = 'procedure_name';
Back to top of file

Where can one find more info about PL/SQL?

Oracle FAQ: PL/SQL code examples


Oracle FAQ: PL/SQL Books
PLNet.org - An open source repository for PL/SQL developers
RevealNet PL/SQL Pipeline - A free community for Oracle developers worldwide
The PL/SQL Cellar - Free Oracle PL/SQL scripts including a bitwise operations package and message
digest algorithms
PLSolutions.com - PL/Solutions provides consulting and training services for the Oracle PL/SQL language
and PL/Vision
The DMOZ PL/SQL Directory
Back to top of file
HOME | ASK QUESTION | ADD FAQ | SEARCH | E-MAIL US

Oracle Objects for OLE (OO4O) FAQ


Topics

What is Oracle Objects for OLE (OO4O)?


How does OO4O compare to ODBC?
Can I use OO4O to access Oracle data from Microsoft applications?
How does one connect to an Oracle Database?
What are the major VB/ODBC limitations that OO4O overcomes?
Where can I get more info about OO4O?

What is Oracle Objects for OLE?


Oracle Objects for OLE (OO4O) is a middleware product manufactured by Oracle Corporation that allows native
access to Oracle7 databases from client applications via the Microsoft OLE (Object Linking and Embedding)
standard. OO4O's predecessor was called Oracle Glue.
Oracle Objects consists of the following three components:
An OLE 2.0 Automation (InProcess) Server - This provides an OLE Automation interface to applications
that support OLE automation scripting such as Visual Basic (VB)
An Oracle Data Control - This is the Visual Basic custom control (VBX)
Two C++ Class Libraries - C-Libraries for Microsoft Foundation Classes (MFC) and Borland (OWL)

How does OO4O compare to ODBC?


OO4O provides native access to Oracle and only Oracle databases. It is faster than ODBC access but one can use
ODBC to connect to a variety of data sources.
Since OO4O closely follows the ODBC query interface model, one can retain over 95% code compatibility between
the OO4O and ODBC versions of the data layer procedures. This translates to very short retooling times in porting
between the two products.

Can I use OO4O to access Oracle data from Microsoft applications?


Yes, you can use OO4O from any Microsoft application that uses the VB-style macro language. This includes Visual
Basic, Excel, and MS-Access.

How does one connect to an Oracle Database?


Sub Form_Load ()
Dim OraSession As Object
Dim OraDatabase As Object
Dim OraDynaset As Object

'Declare variables as OLE Objects

Set OraSession = CreateObject("OracleInProcServer.XOraSession")


Set OraDatabase = OraSession.DbOpenDatabase("SQL*Net_Connect_String",
"scott/tiger", 0&)
MsgBox "Connected to " & OraDatabase.Connect & "@" &
OraDatabase.DatabaseName
'Create the OraDynaset Object and display the first value
Set OraDynaset = OraDatabase.DbCreateDynaset("select empno, ename from emp",
0&)
MsgBox "Employee " & OraDynaset.Fields("empno").value & ", #" &
OraDynaset.Fields("ename").value
End Sub

What are the major VB/ODBC limitations that OO4O overcomes?


(From the Oracle Objects Technical Overview by Keith Majkut):
Visual Basic 3.0 database access is not very client/server oriented. In fact, the Visual Basic database access is really
designed for flatfile databases, but Visual Basic can use ODBC to access SQL databases. Unfortunately, Visual
Basic, by default, makes use of a local SQL engine, called JET to process queries (using the MS JET SQL
implementation, NOT Oracle's). You may bypass the JET engine (using something called SQLPASSTHROUGH,
which causes the SQL to be sent directly to the database), but doing so causes your dynaset to be read-only. You
would then have to update data by constructing SQL insert/delete/update statements. You would not be able to use
the built in AddNew, Delete and Update methods. (Note: SQL statements cannot contain text data > 32K and cannot
contain binary data.)
The drawbacks of the VB/JET/ODBC combination are many:
Rows are accessed via a primary key (unique index). Your table MUST contain a unique index, or else the
resulting dynaset will NOT be updatable. This is an ODBC feature related to the fact that ODBC is based
on Microsoft's SQLServer.
When a dynaset is created, only the primary keys are fetched; rows are not fetched until they are needed.
This sounds reasonable until you realize that it results in multiple queries and many trips to the server.
When a snapshot is created, all rows are immediately fetched. This could potentially be millions of rows.
Table joins are performed locally.
Although views and synonyms can be used, they will cause your dynaset to be read-only.
Column aliases and schema references (such as "SCOTT.EMP") cannot be used without
SQLPASSTHROUGH.

Object names are referenced in UPPER case unless you use SQLPASSTHROUGH. This only works for the
(default) Oracle setting of case-insensitive objects.
There is no support for SQL bind variables (i.e. "SELECT * FROM EMP WHERE ENAME = :name"). If
the value of your variable changes, you need to recreate the SQL statement and dynaset. This means that
the server must reparse the query and refetch the data.
There is no support for PL/SQL bind variables (in/out parameters). The workaround is to pass values in as
literals, and store the return values in a temporary table that you can then query on to get the results.
Multiple data controls (or database opens) use multiple database connections, even if they all reference the
same account on the same database. This can be a serious problem with databases that have a limit on the
total number of connections they will accept.
Oracle Objects has no such drawbacks:
Rows are accessed via their rowid. If a rowid can be obtained, then the data is updatable.
When creating a dynaset, some data is initially fetched and cached locally. Data is fetched and stored
locally as needed, as rows are traversed. Admittedly, this can lead to a large local data cache, so many
tunable cache parameters are provided to improve performance.
Snapshots have not been implemented, since a read-only dynaset is a reasonable equivalent.
Table joins are performed by the server.
Views, synonyms, column aliases and schema references can be used freely. The updatability of database
objects is only dependent SQL updatability rules and on the access you have been granted .
Objects names are not modified in any way. You may use upper or lower case in the names, which are caseinsensitive.
Support for SQL bind variables (i.e. "SELECT * FROM EMP WHERE ENAME = :name") is offered via
the Parameters collection. The server does not have to reparse the query before refetching data.
Support for PL/SQL bind variables is offered (in/out vars) via the Parameters collection.
Multiple data controls (or database opens) referencing the same account on the same database will all share
a single Oracle connection.
At first, the VB/JET/ODBC limitations may not sound serious, but consider a typical production Oracle environment
where most users only have access to data via synonyms and views. This means that VB/JET/ODBC users can only
read, not write data.
Oracle PL/SQL FAQ

Topics

What is PL/SQL and what is it good for?


How can I protect my PL/SQL source code?
Can one print to the screen from PL/SQL?
Can one read/write files from PL/SQL?
Can one use dynamic SQL within PL/SQL?
How does one get the value of a sequence into a PL/SQL variable?
Can one execute an operating system command from PL/SQL?
How does one loop through tables in PL/SQL?
Can one pass an object/table as arguments to remote procedure?
Is there a PL/SQL Engine in SQL*Plus?
Is there a limit on the size of a PL/SQL block?
Where can I find more info about PL/SQL?

Back to Oracle FAQ Index

What is PL/SQL and what is it good for?


PL/SQL is Oracle's Procedural Language extension to SQL. PL/SQL's language syntax, structure and data types
are similar to that of ADA. The language includes object oriented programming techniques such as encapsulation,
function overloading, information hiding (all but inheritance) and is commonly used to write data-centric programs
to manipulate Oracle data.
Back to top of file

How can I protect my PL/SQL source code?


PL/SQL V2.2, available with Oracle7.2, implements a binary wrapper for PL/SQL programs to protect the source
code.
This is done via a standalone utility that transforms the PL/SQL source code into portable binary object code
(somewhat larger than the original). This way you can distribute software without having to worry about exposing
your proprietary algorithms and methods. SQL*Plus and SQL*DBA will still understand and know how to execute
such scripts. Just be careful, there is no "decode" command available.
The syntax is:
wrap iname=myscript.sql oname=xxxx.plb
Back to top of file

Can one print to the screen from PL/SQL?


One can use the DBMS_OUTPUT package to write information to an output buffer. This buffer can be displayed on
the screen from SQL*Plus if you issue the SET SERVEROUTPUT ON; command. For example:
begin
dbms_output.put_line('Look Ma, I can print from PL/SQL!!!');
end;
/
But what if you forget to set serveroutput on? No problem, just type SET SERVEROUTPUT ON once you remember,
and then EXEC NULL;. If you haven't cleared the DBMS_OUTPUT buffer with the disable or enable procedure,
SQL*Plus will display the entire contents of the buffer when it executes this dummy PL/SQL block.
Back to top of file

Can one read/write files from PL/SQL?


Included in Oracle 7.3 is an UTL_FILE package that can read and write operating system files. The directory you
intend writing to has to be in your INIT.ORA file (see UTL_FILE_DIR=... parameter). Before Oracle 7.3 the only
means of writing a file was to use DBMS_OUTPUT with the SQL*Plus SPOOL command.
Copy this example to get started:
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('/tmp', 'myfile', 'w');
UTL_FILE.PUTF(fileHandler, 'Look ma, I''m writing to a file!!!\n');
UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
WHEN utl_file.invalid_path THEN
raise_application_error(-20000, 'ERROR: Invalid path for file or path not
in INIT.ORA.');
END;
Back to top of file

Can one use dynamic SQL within PL/SQL?


From PL/SQL V2.1 one can use the DBMS_SQL package to execute dynamic SQL statements. Eg:
CREATE OR REPLACE PROCEDURE DYNSQL AS
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur, 'CREATE TABLE X (Y DATE)', DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;
/
Another example:
CREATE OR REPLACE PROCEDURE DEPARTMENTS(NO IN DEPT.DEPTNO%TYPE) AS
v_cursor integer;
v_dname char(20);
v_rows
integer;
BEGIN
v_cursor := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(v_cursor, 'select dname from dept where deptno > :x',
DBMS_SQL.V7);
DBMS_SQL.BIND_VARIABLE(v_cursor, ':x', no);
DBMS_SQL.DEFINE_COLUMN_CHAR(v_cursor, 1, v_dname, 20);
v_rows := DBMS_SQL.EXECUTE(v_cursor);
loop
if DBMS_SQL.FETCH_ROWS(v_cursor) = 0 then
exit;
end if;
DBMS_SQL.COLUMN_VALUE_CHAR(v_cursor, 1, v_dname);
DBMS_OUTPUT.PUT_LINE('Deptartment name: '||v_dname);
end loop;
DBMS_SQL.CLOSE_CURSOR(v_cursor);
EXCEPTION
when others then
DBMS_SQL.CLOSE_CURSOR(v_cursor);
raise_application_error(-20000, 'Unknown Exception Raised: '||
sqlcode||' '||sqlerrm);
END;
/
Back to top of file

How does one get the value of a sequence into a PL/SQL variable?
As you might know, oracle prohibits this:
i := sq_sequence.NEXTVAL;
(for some silly reason). But you can do this:
select sq_sequence.NEXTVAL into :i from dual;
Thanks to Ronald van Woensel

Back to top of file

Can one execute an operating system command from PL/SQL?


In Oracle7 there is no direct way to execute an operating system command from PL/SQL. However, one can write
an external program (using one of the precompiler languages,OCI or Perl with Oracle access modules) to act as a
listener on a DBMS_PIPE. You PL/SQL then places requests to run commands in the pipe, the listener picks it up
and runs them. Results are passes back on a different pipe. For an Pro*C example, see chapter 8 of the Oracle
Application Developers Guide. This example is also on the Support Notes CD-ROM that all supported customers
should be getting quarterly. Just search on "DBMS_PIPE".
In Oracle8 you can call external 3GL code in a dynamically linked
library (DLL or shared object). So you just write a library in C doing
what you want, ie in your case a host function taking the command line
as input argument. And that function will be callable from PL/SQL.
So what you have to do is more or less:
1. Write C code in host.c: int host(char *command) { ... }.
2. Compile C code to DLL or shared object, eg
c:\winnt\system32\host.dll.
3. "create or replace library host as 'c:\winnt\system32\host.dll';"
4. "create or replace function host(command in varchar2) return
pls_integer
is external
library host
name "host"
language c
calling standard pascal
parameters (host string, return long);"
Let's say I had a PL/SQL block and I wanted to do a "ls -l" to get a
directory listing. Is there any way to do that?
In C Language, I can do
{
x = system("ls -l");
}
The way most people do that is to use the pipe facility of the DBMS
kernel: set up a pipe for use by a sender (the PL/SQL program that
needs to invoke a command) and a receiver, written in Pro*C, responsible for
executing the command piped by the sender. Maybe there are some tools
around so one doesn't need to code this, as it involves a listener and
multiple server processes on your machine.
Alternatively I have a more complex solution, which uses a table to
pass arguments and the command to execute - just as the DBMS_PIPE package
does internally. You would insert a row into the table and the
listener would execute a command, passing back succession status and
indicating "in progress" on long-running commands. This tools allows for
non-blocking execution of commands.
Back to top of file

How does one loop through tables in PL/SQL?


Look at the following nested loop code example.
DECLARE
CURSOR dept_cur IS
SELECT deptno
FROM dept
ORDER BY deptno;
-- Employee cursor all employees for a dept number
CURSOR emp_cur (v_dept_no DEPT.DEPTNO%TYPE) IS
SELECT ename
FROM emp
WHERE deptno = v_dept_no;
BEGIN
FOR dept_rec IN dept_cur LOOP
dbms_output.put_line('Employees in Department '||
TO_CHAR(dept_rec.deptno));
FOR emp_rec in emp_cur(dept_rec.deptno) LOOP
dbms_output.put_line('...Employee is '||emp_rec.ename);
END LOOP;
END LOOP;
END;
Back to top of file

Can one pass an object/table as arguments to remote procedure?


The only way the same object type can be referenced between two databases is via a database link. Note that is not
enough to just use the same type definitions. Look at this example:
-- Database A: receives a PL/SQL table from database B
CREATE OR REPLACE PROCEDURE pcalled(TabX DBMS_SQL.VARCHAR2S) IS
BEGIN
null;
END;
/
-- Database B: send a PL/SQL table to database A
CREATE OR REPLACE PROCEDURE pcalling IS
TabX DBMS_SQL.VARCHAR2S@DBLINK2;
BEGIN
pcalled@DBLINK2(TabX);
END;
/
Back to top of file

Is there a PL/SQL Engine in SQL*Plus?


No. Unlike Oracle Forms, SQL*Plus does not have a PL/SQL engine. Thus, all your PL/SQL are send directly to the
database engine for execution. This makes it much more efficient as SQL statements are not stripped off and send to
the database individually.
Back to top of file

Is there a limit on the size of a PL/SQL block?


Yes, the max size is not an explicit byte limit, but related to the parse tree that is created when you compile the code.
You can run the following select statement to query the size of an existing package or procedure: SQL> select *
from dba_object_size where name = 'procedure_name'
Back to top of file

Where can I find more info about PL/SQL?


Oracle's PL/SQL Home Page
PLSolutions.com
Back to top of file

Index Search Add FAQ Ask Question

Oracle PL/SQL FAQ


$Date: 17-Dec-2001 $
$Revision: 2.05 $
$Author: Frank Naud $

Topics

What is PL/SQL and what is it used for?


Should one use PL/SQL or Java to code procedures and triggers?
How can one see if somebody modified any code?
How can one search PL/SQL code for a string/key value?
How can one keep a history of PL/SQL code changes?
How can I protect my PL/SQL source code?
Can one print to the screen from PL/SQL?
Can one read/write files from PL/SQL?
Can one call DDL statements from PL/SQL?

Can one use dynamic SQL statements from PL/SQL?


What is the difference between %TYPE and %ROWTYPE?
What is the result of comparing NULL with NULL?
How does one get the value of a sequence into a PL/SQL variable?
Can one execute an operating system command from PL/SQL?
How does one loop through tables in PL/SQL?
How often should one COMMIT in a PL/SQL loop? / What is the best commit strategy?
I can SELECT from SQL*Plus but not from PL/SQL. What is wrong?
What is a mutating and constraining table?
Can one pass an object/table as an argument to a remote procedure?
Is it better to put code in triggers or procedures? What is the difference?
Is there a PL/SQL Engine in SQL*Plus?
Is there a limit on the size of a PL/SQL block?
Where can one find more info about PL/SQL?

Back to Oracle FAQ Index

What is PL/SQL and what is it used for?


PL/SQL is Oracle's Procedural Language extension to SQL. PL/SQL's language syntax, structure and data types
are similar to that of ADA. The PL/SQL language includes object oriented programming techniques such as
encapsulation, function overloading, information hiding (all but inheritance). PL/SQL is commonly used to write
data-centric programs to manipulate data in an Oracle database.
Back to top of file

Should one use PL/SQL or Java to code procedures and triggers?


Internally the Oracle database supports two procedural languages, namely PL/SQL and Java. This leads to questions
like "Which of the two is the best?" and "Will Oracle ever desupport PL/SQL in favour of Java?".
Many Oracle applications are based on PL/SQL and it would be difficult of Oracle to ever desupport PL/SQL. In
fact, all indications are that PL/SQL still has a bright future ahead of it. Many enhancements are still being made to
PL/SQL. For example, Oracle 9iDB supports native compilation of Pl/SQL code to binaries.
PL/SQL and Java appeal to different people in different job roles. The following table briefly describes the
difference between these two language environments:
PL/SQL:
Data centric and tightly integrated into the database Proprietary to Oracle and difficult to port to other database
systems Data manipulation is slightly faster in PL/SQL than in Java Easier to use than Java (depending on your
background)
Java:
Open standard, not proprietary to Oracle Incurs some data conversion overhead between the Database and Java type
systems Java is more difficult to use (depending on your background)
Back to top of file

How can one see if somebody modified any code?


Code for stored procedures, functions and packages is stored in the Oracle Data Dictionary. One can detect code
changes by looking at the LAST_DDL_TIME column in the USER_OBJECTS dictionary view. Example:
SELECT OBJECT_NAME,
TO_CHAR(CREATED,
'DD-Mon-RR HH24:MI') CREATE_TIME,
TO_CHAR(LAST_DDL_TIME, 'DD-Mon-RR HH24:MI') MOD_TIME,

FROM
WHERE
Back to top of file

STATUS
USER_OBJECTS
LAST_DDL_TIME > '&CHECK_FROM_DATE';

How can one search PL/SQL code for a string/ key value?
The following query is handy if you want to know where a certain table, field or expression is referenced in your
PL/SQL source code.
SELECT TYPE, NAME, LINE
FROM
USER_SOURCE
WHERE UPPER(TEXT) LIKE '%&KEYWORD%';
Back to top of file

How can one keep a history of PL/SQL code changes?


One can build a history of PL/SQL code changes by setting up an AFTER CREATE schema (or database) level
trigger (available from Oracle 8.1.7). This way one can easily revert to previous code should someone make any
catastrophic changes. Look at this example:
CREATE TABLE SOURCE_HIST
-- Create history table
AS SELECT SYSDATE CHANGE_DATE, USER_SOURCE.*
FROM
USER_SOURCE WHERE 1=2;
table

CREATE OR REPLACE TRIGGER change_hist

-- Store code in hist

AFTER CREATE ON SCOTT.SCHEMA


-- Change SCOTT to your
schema name
DECLARE
BEGIN
if DICTIONARY_OBJ_TYPE in ('PROCEDURE', 'FUNCTION',
'PACKAGE', 'PACKAGE BODY', 'TYPE') then
-- Store old code in SOURCE_HIST table
INSERT INTO SOURCE_HIST
SELECT sysdate, user_source.* FROM USER_SOURCE
WHERE TYPE = DICTIONARY_OBJ_TYPE
AND NAME = DICTIONARY_OBJ_NAME;
end if;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20000, SQLERRM);
END;
/
show errors
Back to top of file

How can I protect my PL/SQL source code?


PL/SQL V2.2, available with Oracle7.2, implements a binary wrapper for PL/SQL programs to protect the source
code.
This is done via a standalone utility that transforms the PL/SQL source code into portable binary object code
(somewhat larger than the original). This way you can distribute software without having to worry about exposing

your proprietary algorithms and methods. SQL*Plus and SQL*DBA will still understand and know how to execute
such scripts. Just be careful, there is no "decode" command available.
The syntax is:
wrap iname=myscript.sql oname=xxxx.plb
Back to top of file

Can one print to the screen from PL/SQL?


One can use the DBMS_OUTPUT package to write information to an output buffer. This buffer can be displayed on
the screen from SQL*Plus if you issue the SET SERVEROUTPUT ON; command. For example:
set serveroutput on
begin
dbms_output.put_line('Look Ma, I can print from PL/SQL!!!');
end;
/
DBMS_OUTPUT is useful for debugging PL/SQL programs. However, if you print too much, the output buffer will
overflow. In that case, set the buffer size to a larger value, eg.: set serveroutput on size 200000
If you forget to set serveroutput on type SET SERVEROUTPUT ON once you remember, and then EXEC NULL;. If
you haven't cleared the DBMS_OUTPUT buffer with the disable or enable procedure, SQL*Plus will display the
entire contents of the buffer when it executes this dummy PL/SQL block.
Back to top of file

Can one read/write files from PL/SQL?


Included in Oracle 7.3 is an UTL_FILE package that can read and write operating system files. The directory you
intend writing to has to be in your INIT.ORA file (see UTL_FILE_DIR=... parameter). Before Oracle 7.3 the only
means of writing a file was to use DBMS_OUTPUT with the SQL*Plus SPOOL command.
Copy this example to get started:
DECLARE
fileHandler UTL_FILE.FILE_TYPE;
BEGIN
fileHandler := UTL_FILE.FOPEN('/tmp', 'myfile', 'w');
UTL_FILE.PUTF(fileHandler, 'Look ma, I''m writing to a file!!!\n');
UTL_FILE.FCLOSE(fileHandler);
EXCEPTION
WHEN utl_file.invalid_path THEN
raise_application_error(-20000, 'ERROR: Invalid path for file or
path not in INIT.ORA.');
END;
/
Back to top of file

Can one call DDL statements from PL/SQL?


One can call DDL statements like CREATE, DROP, TRUNCATE, etc. from PL/SQL by using the "EXECUTE
IMMEDATE" statement. Users running Oracle versions below 8i can look at the DBMS_SQL package (see FAQ
about Dynamic SQL).
begin
EXECUTE IMMEDIATE 'CREATE TABLE X(A DATE)';
end;
NOTE: The DDL statement in quotes should not be terminated with a semicolon.
Back to top of file

Can one use dynamic SQL statements from PL/SQL?


Starting from Oracle8i one can use the "EXECUTE IMMEDIATE" statement to execute dynamic SQL and PL/SQL
statements (statements created at run-time). Look at these examples. Note that statements are NOT terminated by
semicolons:
EXECUTE IMMEDIATE 'CREATE TABLE x (a NUMBER)';
-- Using bind variables...
sql_stmt := 'INSERT INTO dept VALUES (:1, :2, :3)';
EXECUTE IMMEDIATE sql_stmt USING dept_id, dept_name, location;
-- Returning a cursor...
sql_stmt := 'SELECT * FROM emp WHERE empno = :id';
EXECUTE IMMEDIATE sql_stmt INTO emp_rec USING emp_id;
One can also use the older DBMS_SQL package (V2.1 and above) to execute dynamic statements. Look at these
examples:
CREATE OR REPLACE PROCEDURE DYNSQL AS
cur integer;
rc integer;
BEGIN
cur := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(cur, 'CREATE TABLE X (Y DATE)', DBMS_SQL.NATIVE);
rc := DBMS_SQL.EXECUTE(cur);
DBMS_SQL.CLOSE_CURSOR(cur);
END;
/
More complex DBMS_SQL example using bind variables:
CREATE OR REPLACE PROCEDURE DEPARTMENTS(NO IN DEPT.DEPTNO%TYPE) AS
v_cursor integer;
v_dname char(20);
v_rows
integer;
BEGIN
v_cursor := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(v_cursor, 'select dname from dept where deptno > :x',
DBMS_SQL.V7);
DBMS_SQL.BIND_VARIABLE(v_cursor, ':x', no);
DBMS_SQL.DEFINE_COLUMN_CHAR(v_cursor, 1, v_dname, 20);
v_rows := DBMS_SQL.EXECUTE(v_cursor);
loop
if DBMS_SQL.FETCH_ROWS(v_cursor) = 0 then
exit;
end if;
DBMS_SQL.COLUMN_VALUE_CHAR(v_cursor, 1, v_dname);
DBMS_OUTPUT.PUT_LINE('Deptartment name: '||v_dname);
end loop;
DBMS_SQL.CLOSE_CURSOR(v_cursor);
EXCEPTION
when others then
DBMS_SQL.CLOSE_CURSOR(v_cursor);
raise_application_error(-20000, 'Unknown Exception Raised: '||
sqlcode||' '||sqlerrm);
END;
/
Back to top of file

What is the difference between %TYPE and %ROWTYPE?


The %TYPE and %ROWTYPE constructs provide data independence, reduces maintenance costs, and allows
programs to adapt as the database changes to meet new business needs.
%ROWTYPE is used to declare a record with the same types as found in the specified database table, view or
cursor. Example:
DECLARE
v_EmpRecord emp%ROWTYPE;
%TYPE is used to declare a field with the same type as that of a specified table's column. Example:
DECLARE
v_EmpNo emp.empno%TYPE;
Back to top of file

What is the result of comparing NULL with NULL?


NULL is neither equal to NULL, nor it is not equal to NULL. Any comparison to NULL is evaluated to NULL.
Look at this code example to convince yourself.
declare
a number := NULL;
b number := NULL;
begin
if a=b then
dbms_output.put_line('True, NULL = NULL');
elsif a<>b then
dbms_output.put_line('False, NULL <> NULL');
else
dbms_output.put_line('Undefined NULL is neither = nor <> to
NULL');
end if;
end;
Back to top of file

How does one get the value of a sequence into a PL/SQL variable?
As you might know, one cannot use sequences directly from PL/SQL. Oracle (for some silly reason) prohibits this:
i := sq_sequence.NEXTVAL;
However, one can use embedded SQL statements to obtain sequence values:
select sq_sequence.NEXTVAL into :i from dual;
Thanks to Ronald van Woensel

Back to top of file

Can one execute an operating system command from PL/SQL?


There is no direct way to execute operating system commands from PL/SQL in Oracle7. However, one can write an
external program (using one of the precompiler languages, OCI or Perl with Oracle access modules) to act as a
listener on a database pipe (SYS.DBMS_PIPE). Your PL/SQL program then put requests to run commands in the
pipe, the listener picks it up and run the requests. Results are passed back on a different database pipe. For an Pro*C
example, see chapter 8 of the Oracle Application Developers Guide.

In Oracle8 one can call external 3GL code in a dynamically linked library (DLL or shared object). One just write a
library in C/ C++ to do whatever is required. Defining this C/C++ function to PL/SQL makes it executable. Look at
this External Procedure example.
Back to top of file

How does one loop through tables in PL/SQL?


Look at the following nested loop code example.
DECLARE
CURSOR dept_cur IS
SELECT deptno
FROM dept
ORDER BY deptno;
-- Employee cursor all employees for a dept number
CURSOR emp_cur (v_dept_no DEPT.DEPTNO%TYPE) IS
SELECT ename
FROM emp
WHERE deptno = v_dept_no;
BEGIN
FOR dept_rec IN dept_cur LOOP
dbms_output.put_line('Employees in Department '||
TO_CHAR(dept_rec.deptno));
FOR emp_rec in emp_cur(dept_rec.deptno) LOOP
dbms_output.put_line('...Employee is '||emp_rec.ename);
END LOOP;
END LOOP;
END;
/
Back to top of file

How often should one COMMIT in a PL/SQL loop? / What is the best commit
strategy?
Contrary to popular believe, one should COMMIT less frequently within a PL/SQL loop to prevent ORA-1555
(Snapshot too old) errors. The higher the frequency of commit, the sooner the extents in the rollback segments will
be cleared for new transactions, causing ORA-1555 errors.
To fix this problem one can easily rewrite code like this:
FOR records IN my_cursor LOOP
...do some stuff...
COMMIT;
END LOOP;
... to ...
FOR records IN my_cursor LOOP
...do some stuff...
i := i+1;
IF mod(i, 10000) THEN
-- Commit every 10000 records
COMMIT;
END IF;
END LOOP;
If you still get ORA-1555 errors, contact your DBA to increase the rollback segments.
NOTE: Although fetching across COMMITs work with Oracle, is not supported by the ANSI standard.
Back to top of file

I can SELECT from SQL*Plus but not from PL/SQL. What is wrong?
PL/SQL respect object privileges given directly to the user, but does not observe privileges given through roles. The
consequence is that a SQL statement can work in SQL*Plus, but will give an error in PL/SQL. Choose one of the
following solutions:
Grant direct access on the tables to your user. Do not use roles!
GRANT select ON scott.emp TO my_user;
Define your procedures with invoker rights (Oracle 8i and higher);
Move all the tables to one user/schema.
Back to top of file

What is a mutating and constraining table?


"Mutating" means "changing". A mutating table is a table that is currently being modified by an update, delete, or
insert statement. When a trigger tries to reference a table that is in state of flux (being changed), it is considered
"mutating" and raises an error since Oracle should not return data that has not yet reached its final state.
Another way this error can occur is if the trigger has statements to change the primary, foreign or unique key
columns of the table off which it fires. If you must have triggers on tables that have referential constraints, the
workaround is to enforce the referential integrity through triggers as well.
There are several restrictions in Oracle regarding triggers:
A row-level trigger cannot query or modify a mutating table. (Of course, NEW and OLD still can be
accessed by the trigger) .
A statement-level trigger cannot query or modify a mutating table if the trigger is fired as the result of a
CASCADE delete.
Etc.
Back to top of file

Can one pass an object/table as an argument to a remote procedure?


The only way the same object type can be referenced between two databases is via a database link. Note that it is not
enough to just use the same type definitions. Look at this example:
-- Database A: receives a PL/SQL table from database B
CREATE OR REPLACE PROCEDURE pcalled(TabX DBMS_SQL.VARCHAR2S) IS
BEGIN
-- do something with TabX from database B
null;
END;
/
-- Database B: sends a PL/SQL table to database A
CREATE OR REPLACE PROCEDURE pcalling IS
TabX DBMS_SQL.VARCHAR2S@DBLINK2;
BEGIN
pcalled@DBLINK2(TabX);
END;
/
Back to top of file

Is it better to put code in triggers or procedures? What is the difference?


In earlier releases of Oracle it was better to put as much code as possible in procedures rather than triggers. At that
stage procedures executed faster than triggers as triggers had to be re-compiled every time before executed (unless
cached). In more recent releases both triggers and procedures are compiled when created (stored p-code) and one
can add as much code as one likes in either procedures or triggers.
Back to top of file

Is there a PL/SQL Engine in SQL*Plus?


No. Unlike Oracle Forms, SQL*Plus does not have an embedded PL/SQL engine. Thus, all your PL/SQL code is
sent directly to the database engine for execution. This makes it much more efficient as SQL statements are not
stripped off and sent to the database individually.
Back to top of file

Is there a limit on the size of a PL/SQL block?


Yes, the max size is not an explicit byte limit, but related to the parse tree that is created when you compile the code.
You can run the following select statement to query the size of an existing package or procedure:
SQL> select * from dba_object_size where name = 'procedure_name';
Back to top of file

Where can one find more info about PL/SQL?

Oracle FAQ: PL/SQL code examples


Oracle FAQ: PL/SQL Books
PLNet.org - An open source repository for PL/SQL developers
RevealNet PL/SQL Pipeline - A free community for Oracle developers worldwide
The PL/SQL Cellar - Free Oracle PL/SQL scripts including a bitwise operations package and message
digest algorithms
PLSolutions.com - PL/Solutions provides consulting and training services for the Oracle PL/SQL language
and PL/Vision
The DMOZ PL/SQL Directory
Back to top of file
HOME | ASK QUESTION | ADD FAQ | SEARCH | E-MAIL US

Oracle SQL*Net/ Net8 FAQ


Topics

What is SQL*Net/ Net8?


What is the difference between Sql*Net V1, V2 and NET8?
How does one configure SQL*Net?

I have some trouble with SQL*Net. How can I produce a trace file?
How can I set up a dedicated server connection?
Can I upgrade to SQL*Net V2 if I still have V1 clients?
How can I enable dead connection detection?
What are inband and out of band breaks?
What can be done to increase SQL*Net performance?
Can one get connected to a system regardless of machine failure?
Can one grant or restrict access to a system via SQL*Net?
Where can I get more info about SQL*Net/ Net8?
Oracle Names Topics:
How does one setup an Oracle Names Server?
How to get your listener to register itself with the Names Server?
How does one register an Oracle Names Server Entry?
How can I check if a listener registered itself with the Names Server?
Connection Manager Topics:
What is the Connection Manager and what is it good for?
How does one configure the Connection Manager?
How does one route data through the Connection Manager?

Back to Oracle FAQ Index

What is SQL*Net/ Net8?


NET8 (called SQL*NET prior to Oracle8) is Oracle's client/server middleware product that offers transparent
connection from client tools to the database, or from one database to another. SQL*Net/ Net8 works across multiple
network protocols and operating systems.
TNS or Transparent Network Substrate is Oracle's networking architecture. TNS provides a uniform application
interface to enable network applications to access the underlying network protocols transparently.
The TNS architecture consists of three software components: TNS-based applications, Oracle Protocol Adapters
(OPA), and networking software like TCP/IP.
Back to top of file

What is the difference between SQL*Net V1, V2 and NET8?

Default port
Start
command
Stop
command
Connect
string

SQL*Net V1

SQL*Net V2

Net8

1525/tcp

1521/tcp

1521/tcp

tcpctl start

lsnrctl start

lsnrctl start

tcpctl stop

lsnrctl stop

lsnrctl stop

protocol:host:sid eg.
T:SRV1:DB1

Specified in TNSNAMES.ORA

Specified in TNSNAMES.ORA

tnsnames.ora, sqlnet.ora &


listener.ora
TWO_TASK=

tnsnames.ora, sqlnet.ora &


listener.ora
TWO_TASK=

Config files /etc/oratab


Env variable LOCAL=
Back to top of file

How does one configure SQL*Net?


Most people (myself included) prefer to edit the SQL*Net configuration files by hand. The only "officially
supported" configuration method, however, is via the Oracle Net8 Assistant or Oracle Net8 Easy Config utility
(previously called Oracle Network Manager).
This configuration utility is PC based. You need to generate the necessary files on your PC and FTP or copy them to
the relevant operating systems you use Oracle on.
Look at the following sample configuration files:
$ORACLE_HOME/network/admin/sqlnet.ora
------------------------------------automatic_ipc = ON
# Set to OFF for PC's
trace_level_client = OFF
# Set to 16 if tracing is required
sqlnet.expire_time = 0
# Idle time in minutes
sqlnet.authentication_services = (ALL)
names.directory_lookup = (TNSNAMES,ONAMES)
names.default_domain = world
name.default_zone = world
$ORACLE_HOME/network/admin/tnsnames.ora
--------------------------------------dbname1, aliasname1, aliasname2 =
(description =
(address_list =
(address =
(protocol = tcp)
(host = yourHost.domain)
(port = 1521)
)
)
(connect_data =
(sid = yourSID)
)
)
$ORACLE_HOME/network/admin/listener.ora
--------------------------------------LISTENER =
# Listener name is LISTENER
(address_list =
(address=
(protocol=ipc)
(key=yourSID)
)
(address=
(protocol = tcp)
(host = yourHost.domain)
(port = 1521)
)
)
STARTUP_WAIT_TIME_LISTENER = 0
CONNECT_TIMEOUT_LISTENER = 10
TRACE_LEVEL_LISTENER = ON
TRACE_FILE_LISTENER = $ORACLE_HOME/network/trace/listener.trc

SID_LIST_LISTENER =
(SID_LIST=
(SID_DESC=
(SID_NAME=yourSID)
(ORACLE_HOME=YOUR_ORACLE_HOME)
)
)
NOTE: A wrong TNSNAMES.ORA entry on a line will block all valid entries below. Copy names to the top until
you find the incorrect entry.
Back to top of file

I have some trouble with SQL*Net. How can I produce a trace file?
Create/edit your SQLNET.ORA file. You will find this file in one of the following locations (SQL*Net V2 searches
for it in this order):
Directory pointed to by the TNS_ADMIN parameter ($TNS_ADMIN on Unix)
/etc (Unix only)
/var/opt/oracle (Unix only)
$ORACLE_HOME/network/admin or net8/admin directory
Your SQLNET.ORA file should contain the following lines to produce a trace file:
trace_level_client=16
trace_unique_client=yes
Sometimes it is useful to only trace TNSPING packets. Add the following parameters to your SQLNET.ORA file:
TNSPING.TRACE_LEVEL = 16
TNSPING.TRACE_DIRECTORY = /tmp/tnsping/
The following parameters are also worth setting:
trace_file_client = cli.trc
trace_directory_client = <path_to_trace_dir>
log_file_client = sqlnet.log
log_directory_client = <path_to_log_dir>
Back to top of file

How can I set up a dedicated server connection?


When you configue your database to use MTS (Multi-threaded server), all client requests are handed off to one of
the shared server processes by the listener, via a dispatcher. If you want certain clients to use a dedicated Server
process, you need to set the dedicated server option in your database connect string: ie.
SQLPLUS SCOTT/TIGER@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)
(PORT=1521)
(NODE=yourServerName))) (CONNECT_DATA=(SID=yourSid) (SERVER=DEDICATED)))
You can also edit your TNSNAMES.ORA file and add the (SERVER=DEDICATED) part in the
CONNECT_DATA list or simply set USE_DEDICATED_SERVER=ON in your SQLNET.ORA file.
Back to top of file

Can I upgrade to SQL*Net V2 if I still have V1 clients?


SQL*Net V1 cannot talk with SQL*Net V2, and vice versa. The only way to overcome this problem is to run
SQL*Net V1 and V2 simultaneously on the same database server. You can then install SQL*Net V2 on your clients
as time permits. SQL*Net V1 and V2 can coexist on the same server, or on the same client.
You can also list V1 connect strings in your TNSNAMES.ORA file. Eg:
ORA1_NET1 = T:machine_name/port:database_name
Note that SQL*Net V1 is not available from version 7.3 of the database.

Back to top of file

How can I enable dead connection detection?


Dead database connections can be detected and killed by SQL*Net if you specify the SQLNET.EXPIRE_TIME=n
parameter in your SQLNET.ORA file (usually in $ORACLE_HOME/network/admin). This parameter will instruct
SQL*Net to send a probe through the network to the client every n minutes, if the client doesn't respond, it will be
killed.
NOTE: This parameter is only useful on the database server side, specifying it on a client workstation will have no
effect.
Back to top of file

What are inband and out of band breaks?


Data exceptions like Control-C can be transmitted as part of the regular data stream (inband) or as a separate
asyncronious message (outband). Obviously outband breaks are much faster as they can interrupt the flow of data.
Out Of Bound Breaks (OOB) are enabled by default. One can disable OOB from the SQLNET.ORA file:
DISABLE_OOB=on
Back to top of file

What can be done to increase SQL*Net performance?


1.

While a SQL statement is running SQL*Net polls the client continuously to catch CONTROL-C situations.
This results into a lot of poll and fstat system calls.
The following SQLNET.ORA parameter can be specified to reduce polling overhead on your system:
BREAK_POLL_SKIP=n # Number of packets to skip between checking for
breaks (default=4)

2.

Prespawned server sessions. You can tell the listener to start up a pool of idle server processes. When a
connection request is made, it doesn't have to start a server process; it just hands one of the idle processes to
the client (and then starts a new connection in its own time). This is configured in LISTENER.ORA, in the
SID_LIST_LISTENER section, as follows:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = yourSID)
(PRESPAWN_MAX = 50)
(PRESPAWN_LIST =
(PRESPAWN_DESC = (PROTOCOL = TCP) (POOL_SIZE = 5)
(TIMEOUT = 2))))
)
PRESPAWN_MAX: if there are over 50 sessions connected to the database, the listener won't prespawn
any more.
POOL_SIZE: the listener will maintain an idle pool of 5 server processes. TIMEOUT: after a client
disconnects, the listener will keep the freed-up server process around for two minutes, waiting for a new
connection request, before killing that process.
Multiple listeners with load balancing. You can start multiple listeners on a server, and reference all of the
listeners in the TNSNAMES.ORA file. When a client makes a connection request, the SQL*Net client will
randomly pick one of the listeners to contact.
In LISTENER.ORA, specify multiple listeners as in:
# Define listener A...

3.

STARTUP_WAIT_TIME_LISTENER_A = 0
CONNECT_TIMEOUT_LISTENER_A = 10
LISTENER_A=
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = yourHost.domain)
(PORT = 1521)))
SID_LIST_LISTENER_A =
(SID_LIST =
(SID_DESC =
(SID_NAME = yourSID)
(PRESPAWN_MAX = 50)))
# Define the second listener...
STARTUP_WAIT_TIME_LISTENER_B = 0
CONNECT_TIMEOUT_LISTENER_B = 10
LISTENER_B=
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = yourHost.domain)
(PORT = 1522)))
SID_LIST_LISTENER_B =
(SID_LIST =
(SID_DESC =
(SID_NAME = yourSID)
(PRESPAWN_MAX = 50)))
The TNSNAMES.ORA service for this database would be something like:
oradb1.world =
(description_list=
(description=
(address_list=
(address=
(protocol=tcp)
(host=yourHost.domain)
(port=1521)))
(connect_data =
(sid = yourSID)))
(description =
(address_list =
(address=
(protocol=tcp)
(host=yourHost.domain)
(port=1522)))
(connect_data =
(sid = yourSID))))
Back to top of file

Can one get connected to a system regardless of machine failure?


You can place multiple address entries for a single connection alias in the TNSNAMES.ORA file. This means that
you can connect to a database, even if some kind of physical failover occurred. Look at the following example:
oradb1 = (DESCRIPTION =
(ADDRESS_LIST =

(ADDRESS =
(COMMUNITY = TCP_COMM)
(PROTOCOL = TCP)
(HOST = Machine01))
(ADDRESS =
(COMMUNITY = TCP_COMM)
(PROTOCOL = TCP)
(HOST = Machine02)))
(CONNECT_DATA=(
(SID=oradb1))))
Suppose Machine01 is down, then every new SQL*NET connection using service oradb1 will automatically login to
Machine02. However, there is one restriction, the SID must be the same on both machines. This feature can provide
guaranteed login for application servers and for the Oracle Parallel Server.
Back to top of file

Can one grant or restrict access to a system via SQL*Net?


Yes, create a protocal.ora file like this:
tcp.validnode_checking = yes
tcp.invited_nodes = (www.orafaq.org,139.185.5.111)
tcp.excluded_nodes = (133.17.15.21)
Back to top of file

Where can one get more info about SQL*Net/ Net8?


SQL*NET 1-2-3
Download SQL*Net V2 Light for DOS
Back to top of file

How does one setup an Oracle Names Server


Create a domain database: Run script $ORACLE_HOME/network/admin/namesins.sql
From a Windows9x/ NT workstation, start the Oracle Net8 Assistant and configure
For server start the names server: namesctl start
Back to top of file

How to get your listener to register itself with the Names Server?
Edit your LISTENER.ORA file and add a line USE_PLUGANDPLAY_listener_name=ON for each listener defined
on your machine. Secondly, assign a GLOBAL_DBNAME parameter for each listener.
Sample LISTENER.ORA file:
USE_PLUG_AND_PLAY_LISTENER = ON
LISTENER =
(ADDRESS_LIST =
(ADDRESS=
(PROTOCOL=IPC)
(KEY= wblp-nt-011b_orcl.companyX.com)

)
(ADDRESS=
(PROTOCOL=IPC)
(KEY= orcl)
)
(ADDRESS =
(COMMUNITY = TCPIP.companyX.com)
(PROTOCOL = TCP)
(Host = wblp-nt-011b.companyX.com)
(Port = 1526)
)
)
STARTUP_WAIT_TIME_LISTENER = 0
CONNECT_TIMEOUT_LISTENER = 10
TRACE_LEVEL_LISTENER = OFF
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = wblp-nt-011b_orcl.companyX.com)
(SID_NAME = orcl)
(ORACLE_HOME = /)
(PRESPAWN_MAX = 10)
)
)
Back to top of file

How does one register an Oracle Names Server Entry?


Oracle Names Server entries are normally entered from the Oracle Network Manager (V7) or the Oracle Net8
Assistant. Both these tools run from your desktop.
You can also manually register an entry on your server using the NAMESCTL command. Eg:
NAMESCTL> register mydb.world -t oracle_database -d
(description=(address=(protocol=tcp)(host=123.45.67.8)(port=1526))
(connect_data=(sid=MYDB)))
NOTE: the whole command must be entered on one line. Also, make sure you register this database with all Names
Servers running in your domain.
To check if your entry is correctly recorded in the Names Server, issue this command:
NAMESCTL> query mydb.world *
Back to top of file

How can I check if a listener registered itself with the Names Server?
Issue the LSNRCTL command and type either SERVICES or STATUS. If the listener successfully registered itself
with the Oracle Names server you will notice the keyword "Registered" next to the service name. Example:
Services Summary...
oraweb(Registered)
has 1 service handler(s)
Back to top of file

What is the Connection Manager and what is it good for?


The Oracle Connection Manager (CMan) is a Net8 process that relays network traffic to a different address, and
optionally changes its characteristics. The Connenction manager is commonly used for the following:

Connenction Concentration
Access Control
Multiprotocol Support
Provide Java applets to connect to a database that is not on the machine the Java applet was downloaded
from.
Back to top of file

How does one configure the Connection Manager?


The CMAN.ORA file specify Connection Manager configuration details. Look at this sample CMAN.ORA file:
CMAN = (ADDRESS=(PROTOCOL=tcp)(HOST=141.145.83.4)(PORT=1610))
CMAN_ADMIN = (ADDRESS=(PROTOCOL=tcp)(HOST=141.145.83.4)(PORT=1650))
CMAN_RULES = (RULE_LIST =
(RULE = (SRC=141.145.*.*)
(DST=141.145.*.*)
(SRV=ed23)
(ACT=ACC)
))
CMAN_PROFILE = (PARAMETER_LIST=
(MAXIMUM_RELAYS=8)
(LOG_LEVEL=1)
(TRACING=NO)
(SHOW_TNS_INFO=YES)
(RELAY_STATISTICS=NO)
)
Back to top of file

# Wildcard is "x"

# Default is normally too small

How does one route data through the Connection Manager?


Code a TNSNAMES.ORA entry with two addesses. The first addres specifies the address CM is listening on (coded
in CMAN.ORA). The socond is the address the traffic must be routed to. You also need to specify
SOURCE_ROUTE=YES.
ED23_cman =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS=(PROTOCOL=TCP)(HOST=141.145.83.4)(PORT=1610))
(ADDRESS=(PROTOCOL=TCP)(HOST=zaedu2.za.oracle.com)(PORT=1923))
)
(CONNECT_DATA =
(SERVICE_NAME = ed23)
)
(SOURCE_ROUTE = YES)
)
Back to top of file
_

Oracle SQL FAQ


Topics

What is SQL and where does it come from?


How can I eliminate duplicate values in a table?
How can I generate primary key values for my table?
How can I get the time difference between two date columns?
How does one count different data values in a column?
How does one count/sum RANGES of data values in a column?
Can one only retrieves the Nth row from a table?
Can one only retrieve rows X to Y from a table?
How does one select EVERY Nth row from a table?
How does one select the TOP N rows from a table?
How does one code a tree-structured query?
How does one code a matrix report in SQL?
How to implement if-then-else in a select statement?
How can one dump/ examine the exact content of a database column?
Can one drop a column from a table?
Can one rename a column in a table?
How can I change my Oracle password?
How does one find the next value of a sequence?
Workaround for snapshots on tables with LONG columns
Where can I get more info about SQL?

Back to Oracle FAQ Index

What is SQL and where does it come from?


Structured Query Language (SQL) is a language that provides an interface to relational database systems. SQL was
developed by IBM in the 1970s for use in System R. SQL is a de facto standard, as well as an ISO and ANSI
standard. SQL is often pronounced SEQUEL.
In common usage SQL also encompasses DML (Data Manipulation Language), for INSERTs, UPDATEs, DELETEs
and DDL (Data Definition Language), used for creating and modifying tables and other database structures.
The development of SQL is governed by standards. A major revision to the SQL standard was completed in 1992,
called SQL2. SQL3 support object extensions and will be (partially?) implemented in Oracle8.
Back to top of file

How can I eliminate duplicates values in a table?


Choose one of the following queries to identify or remove duplicate rows from a table leaving one record:
Method 1:
SQL> DELETE FROM table_name A WHERE ROWID > (
2
SELECT min(rowid) FROM table_name B
3
WHERE A.key_values = B.key_values);
Method 2:
SQL> create table table_name2 as select distinct * from table_name1;

SQL> drop table_name1;


SQL> rename table_name2 to table_name1;
Method 3: (thanks to Kenneth R Vanluvanee)
SQL> Delete from my_table where rowid not in(
SQL>
select max(rowid) from my_table
SQL>
group by my_column_name );
Method 4: (thanks to Dennis Gurnick)
SQL> delete from my_table t1
SQL> where exists (select 'x' from my_table t2
SQL>
where t2.key_value1 = t1.key_value1
SQL>
and t2.key_value2 = t1.key_value2
SQL>
and t2.rowid
> t1.rowid);
Note: If you create an index on the joined fields in the inner loop, you for all intensive purposes eliminate N^2
operations (no need to loop through the entire table on each pass by a record).
Back to top of file

How can I generate primary key values for my table?


Create your table with a NOT NULL column (say SEQNO). This column can now be populated with unique values:
SQL> UPDATE table_name SET seqno = ROWNUM;
or use a sequences generator:
SQL> CREATE SEQUENCE sequence_name START WITH 1 INCREMENT BY 1;
SQL> UPDATE table_name SET seqno = sequence_name.NEXTVAL;
Finally, create a unique index on this column.
Back to top of file

How can I get the time difference between two date columns
select floor((date1-date2)*24*60*60)/3600)
|| ' HOURS ' ||
floor((((date1-date2)*24*60*60) floor(((date1-date2)*24*60*60)/3600)*3600)/60)
|| ' MINUTES ' ||
round((((date1-date2)*24*60*60) floor(((date1-date2)*24*60*60)/3600)*3600 (floor((((date1-date2)*24*60*60) floor(((date1-date2)*24*60*60)/3600)*3600)/60)*60)))
|| ' SECS ' time_difference
from
...
Back to top of file

How does one count different data values in a column?


select dept, sum( decode(sex,'M',1,0)) MALE,
sum( decode(sex,'F',1,0)) FEMALE,
count(decode(sex,'M',1,'F',1)) TOTAL
from
my_emp_table
group by dept;
Back to top of file

How does one count/sum RANGES of data values in a column?


A value x will be between values y and z if GREATEST(x, y) = LEAST(x, z). Look at this example:
select f2,
count(decode(greatest(f1,59), least(f1,100), 1, 0)) "Range 60100",
count(decode(greatest(f1,30), least(f1, 59), 1, 0)) "Range 3059",
count(decode(greatest(f1,29), least(f1, 0), 1, 0)) "Range 0029"
from
my_table
group by f2;
For equal size ranges it migth be easier to calculate it with DECODE(TRUNC(value/range), 0, rate_0, 1, rate_1, ...).
Eg.
select ename "Name", sal "Salary",
decode( trunc(f2/1000, 0), 0, 0.0,
1, 0.1,
2, 0.2,
3, 0.31) "Tax rate"
from
my_table;
Back to top of file

Can one only retrieves the Nth row from a table?


Ravi Pachalla provided this solution:
SELECT f1 FROM t1
WHERE rowid = (
SELECT rowid FROM t1
WHERE rownum <= 10
MINUS
SELECT rowid FROM t1
WHERE rownum < 10);
Please note, there is no explicit row order in a relational database. However, this query is quite fun and may even
help in the odd situation.
Back to top of file

Can one only retrieve rows X to Y from a table?


To display rows 5 to 7, construct a query like this:
SELECT *
FROM
tableX
WHERE rowid in (
SELECT rowid FROM tableX
WHERE rownum <= 7
MINUS
SELECT rowid FROM tableX
WHERE rownum < 5);
Please note, there is no explicit row order in a relational database. However, this query is quite fun and may even
help in the odd situation.
Back to top of file

How does one select EVERY Nth row from a table?


One can easily select all even, odd, or Nth rows from a table using SQL queries like this:
Method 1: Using a subquery
SELECT *
FROM
emp
WHERE (ROWID,0) IN (SELECT ROWID, MOD(ROWNUM,4)
FROM
emp);
Method 2: Use dynamic views (available from Oracle7.2):
SELECT *
FROM
( SELECT rownum rn, empno, ename
FROM emp
) temp
WHERE MOD(temp.ROWNUM,4) = 0;
Please note, there is no explicit row order in a relational database. However, these queries are quite fun and may
even help in the odd situation.
Back to top of file

How does one select the TOP N rows from a table?


Form Oracle8i one can have an inner-query with an ORDER BY clause. Look at this example:
SELECT *
FROM
(SELECT * FROM my_table ORDER BY col_name_1 DESC)
WHERE ROWNUM < 10;
Use this workaround with prior releases:
SELECT *
FROM my_table a
WHERE 10 >= (SELECT COUNT(DISTINCT maxcol)
FROM my_table b
WHERE b.maxcol >= a.maxcol)
ORDER BY maxcol DESC;
Back to top of file

How does one code a tree-structured query?


This is definitely non-relational (enough to kill Codd and then make him roll in his grave) and is a feature I have not
seen in the competition.
The definitive example is in the example SCOTT/TIGER database, when looking at the EMP table (EMPNO and
MGR columns). The MGR column contains the employee number of the "current" employee's boss.
You have available an extra pseudo-column, LEVEL, that says how deep in the tree you are. Oracle can handle
queries with a depth up to 255.
select LEVEL, EMPNO, ENAME, MGR
from EMP
connect by prior EMPNO = MGR
start with MGR is NULL;
You can get an "indented" report by using the level number to substring or lpad a series of spaces and concatenate
that to the string.
select lpad(' ', LEVEL * 2) || ENAME ........
You use the start with clause to specify the start of the tree(s). More than one record can match the starting
condition. One disadvantage of a "connect by prior" is that you cannot perform a join to other tables. Still, I have not
managed to see anything else like the "connect by prior" in the other vendor offerings and I like trees. Even trying to
doing this programmatic ally in embedded SQL is difficult as you have to do the top level query, for each of them

open a cursor to look for child nodes, for each of these open a cursor .... Pretty soon you blow the cursor limit for
your installation.
The way around this is to use PL/SQL, open the driving cursor with the "connect by prior" statement, and the select
matching records from other tables on a row-by-row basis, inserting the results into a temporary table for later
retrieval.
Back to top of file

How does one code a matrix report in SQL?


Look at this example query with sample output:
SELECT *
FROM (SELECT job,
sum(decode(deptno,10,sal))
sum(decode(deptno,20,sal))
sum(decode(deptno,30,sal))
sum(decode(deptno,40,sal))
FROM scott.emp
GROUP BY job)
ORDER BY 1;

DEPT10,
DEPT20,
DEPT30,
DEPT40

JOB
DEPT10
DEPT20
DEPT30
DEPT40
--------- ---------- ---------- ---------- ---------ANALYST
6000
CLERK
1300
1900
950
MANAGER
2450
2975
2850
PRESIDENT
5000
SALESMAN
5600
Back to top of file

How to implement if-then-else in a select statement?


The Oracle decode function acts like a procedural statement inside an SQL statement to return different values or
columns based on the values of other columns in the select statement.
Some examples:
select decode(sex, 'M', 'Male',
'F', 'Female',
'Unknown')
from
employees;
select a, b, decode( abs(a-b), a-b, 'a > b',
0,
'a = b',
'a < b')
from tableX;
select decode( GREATEST(A,B), A, 'A is greater than B', 'B is greater
than A')...
Note: The decode function is not ANSI SQL and are rarely implemented in other RDBMS offerings. It is one of the
good things about Oracle, but use it sparingly if portability is required.
Back to top of file

How can one dump/ examine the exact content of a database column?
SELECT DUMP(col1)
FROM tab1
WHERE cond1 = val1;
DUMP(COL1)
------------------------------------Typ=96 Len=4: 65,66,67,32
For this example the type is 96, indicating CHAR, and the last byte in the column is 32, which is the ASCII code for
a space. This tells us that this column is blank-padded.
Back to top of file

Can one drop a column from a table?


From Oracle8i one can DROP a column from a table. Look at this sample script, demonstrating the ALTER TABLE
table_name DROP COLUMN column_name; command.
With previous releases one can use Joseph S. Testa's DROP COLUMN package that can be downloaded from
http://www.oracle-dba.com/ora_scr.htm.
Other workarounds:
1. SQL> update t1 set column_to_drop = NULL;
SQL> rename t1 to t1_base;
SQL> create view t1 as select <specific columns> from t1_base;
2. SQL> create table t2 as select <specific columns> from t1;
SQL> drop table t1;
SQL> rename t2 to t1;
Back to top of file

Can one rename a column in a table?


No, this is listed as Enhancement Request 163519. Workarounds:
1. rename t1 to t1_base;
create view t1 <column list with new name> as select * from t1_base;
2. create table t2 <column list with new name> as select * from t1;
drop table t1;
rename t2 to t1;
Back to top of file

How can I change my Oracle password?


Issue the following SQL command: ALTER USER <username> IDENTIFIED BY <new_password>
/
From Oracle8 you can just type "password" from SQL*Plus, or if you need to change another user's password, type
"password user_name".
Back to top of file

How does one find the next value of a sequence?


Perform an "ALTER SEQUENCE ... NOCACHE" to unload the unused cached sequence numbers from the Oracle
library cache. This way, no cached numbers will be lost. If you then select from the USER_SEQUENCES dictionary
view, you will see the correct high water mark value that would
Forms 4.5 , Reports 2.5, SQL*Plus, PL/SQL Questions asked during mock interview
Forms 4.5 :

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.
40.
41.

Which trigger will fire first ? Block level or item level .


List mouse triggers in forms 4.5
Steps in displaying multiple records in control block
How to integrate reports with graphics?
What are the types of relationships in Forms 4.5?
Which triggers are generated by forms during the creation of Master-Detail relationship?
How will you delete the total transaction in a Master-Detail situation without writing code?
When does ON-POPULATE-DETAILS tigger fire?
How do you generate sequential numbers for key0fields ( eg. Purchase Order number )
What trigger fires when the value in Radio button is changed?
Can a null value be inserted using radio button?
How will you set the value of radio button when the value is begin queried from the db?
If a null value or other values is queried, how is the radio button set?
What are the diff types of list Items available?
How will you populate a list item dynamically?
How will you implement duplicate check using Record Groups ?
How will you stop the user dynamically to Insert record in tables?
What triggers will not fire in Enter Query mode by default?
What is the maximum limit of Timer expiry/
What will be the Form_Status after the DB Commit is fired?
What are Global variables? What are the advantages?
How do you create reusable componentes in forms?
What is the sequence of triggers fired in Navigation to other item When validation is 1.Item level and 2. Block
level?
what are form parameters?
What is referencing?
What are the locking mechanism used in F45?
how will you inforce security in forms?
What are the difference between WHEN-VALIDATE-ITEM and POST-CHANGE trigger.
What is Record group and what are the advantages of having it.
What is the differences between Tlist,ComboBox and PopList properties of list items.
What are the differences between copying and referencing an object.
What is MDI Window.
What is the procedure to call a Microsoft Application from forms 4.5.
What is VBX controls and how it helps to build an application in Forms 4.5.
How Parameters will be passed to other Oracle tools.
What do you mean by debugger in Forms 4.5
While debugging can we change the script or not.
Can We have an OLE server for Oracle application.
What is meant by UserExits and how we You will call it from your forms 4.5 application.
What are the various triggers that Reports 2.5 supports.
What is icon.

42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.

How many(minimum) groups are required to prepare a Matrix Report.


What do you mean by bind parameter and lexical parameter.
What are the various differences in Forms 3.0 and Forms 4.5
Can I have a HTML document from Forms 45 application.
What do you mean by activation style property of an OLE object.
What is difference in Object embedding and object Linking.
What are the situations in which we can go for embedding and in which we can go for Linking.
What are the difference between Post-fetch and Post-Query trigger and when they will fire.
What is difference between following built-ins
Create_group_with_query and Populate_group_with_query.
How you can change menu type property
Can you tell something about TOOLBAR.
What are the sequence of commit processing triggers
can you create dynamic LOV.
How you will control transaction in MDI.
what do you mean by session in MDI.
Do you use global variables and parameters.
Can you tell something about window based triggers.

Reports 2.5 :

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.

How will you implement conditional highliting in Reports 2.5?


How many triggers are available and when are they used?
What are the diff types of layouts available?
What are the steps to create your own layouts?
What are the steps to create report containg two diff layouts?
How do you refer field values and parameter values in PL/SQL code in reports?
How do you print the value of a parameter?
How do you restrict that only ten records are printed on one page?
How do you print the name in Vertical Orientation in a Matrix report?
Diff bet report writer 1.1 and 2.5?
Can you write pl/sql in reports 1.1?
How do you give a page level break in 2.5?
How many groups and queries should there be in a matrix report in 1.1 and 2.5?
What is an anchor in Reports 2.5.
Can you change the retrieved value of reports.

SQL*Plus, PL/SQL, ORACLE Concepts :

1.
2.
3.
4.
5.
6.
7.
8.

What are the minimum priveleges required to be given to a newly created user?
What is a synonym? Diff between a view and a synonym
If Db is mounted but not open, which view can U access
Contents of a control file
How to mirror a control file?
What is a instance?
Where does oracle log its errors?
Which process does automatic recovery if an instance fails before writing into datafile but after issuing a
commit statement?
9. How can u maintain consistency across forms?
10. How do constraints differ from DB triggers?

11. If rollback statement has been dropped or corrupted( eg. By deleting the file in O.S ) what will hapen during
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.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.

startup of the instance? How can the situation be handled?


What are the issues to be attended to when a tablespace has to be designed and created?
When will you experience the following error - Snapshot too old How can it be attended?
What is a mutating and a constraining table?
How do you monitor locks in Oracle?
If a user has locked a resource for a long time and is not using it, How will you handle the situation and release
the resource?
What are the differences bet a trigger and a stored procedure?
What is a pl/sql table?
What is a record datatype?
What will happen when a table begin accessed by a stored procedure is dropped?
What is table stripping?
Which view will give the details of datafiles?
Which default tablespace is created by ORACLE?
How do you decide the size of the DB block ?
How do you increase the DB block size?
What are priveleges?
What are tuning steps?
What are the diagnostic tools available for Tuning?
What are the advantages of stored procedures?
If a user does have access rights on a table but has executable rights on a procedure accessing that table; what
will happen?
what will happen when importing a table with duplicates in it?
What is a Instance?
Can you have multiple instances of the same DB/
Can you share bet two instances?
What features are provided by Oracle for DB Audit Trail?
How do you avoid using indexes?
What is cluster? How is it stored?
What is ananymous block?
If a SQL statements are given one by one from the SQL prompt and if they are written in a file and executed
then what will be the difference?
Is it possible to use a index in SQL?
What is the criteria for creating a index?
Will droping a index and recreating it increase performance? If yes, Why?
What is analyzing a table?
Diff bet Union and Union All?
Result of count(*) and count(field name) , DIFF?
What are DCL statements?
What is a exetent, segment?
How many types of segments exists in Oracle?
Can you create rollback segments and data segments explicitly?
How are execptions raised in pl/sql?
Implicit and explicit cursors, diff?
Can you use DDL statements in PL/SQl?
How is a SQL statement parsed?
How can you delete duplicates in a table?
what is the diff bet rowid and rownum?
What are hierarchical queries? ( connect by prior)
What is a transaction?

58. What is a read lock?


59. What are SQL statements you can use in case of read transcation?
60. In case of a trigger firing another trigger and that in turn firing another and so on ; upto what level is this kind of
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.
93.

nesting allowed ? ( ans. 32 )


What is referential integrity?
Normalisation and De-normalisation?
Diff bet 2nd and 3rd normal form?
Optimiser 1. Cost based 2. Rule based . Diff? Which is used by Oracle?
When is index recreated or remapped?
Diff bet truncate and delete?
Will a After-delete trigger fire when the table is truncated?
What are the things you will keep in mind when writing SQL statement?
In case of a join statement which should be the driving table? ( ans. With max number of records.)
Upto what level can you nest blocks in PL/SQL ? ( ans. 200 depending on the stack status ).
What are the multithreaded server and how it is different from dedicated server .
What are the new features incorporated in ORACLE 7.2 version.
What are the various difference between ORACLE 6.0 ORCALE7.0.
How many types of triggers U have used in your application.
How are the various variables in Proc and how we are declaring it.
What is meant by Indicator variable in Pro*C
What is difference between SQLCA and ORACA.
How You are trapping errors in Pro*C program
What is difference between UserExits and Pro*C program
What are the various difference in UNIX and WINDOWS95 Operating systems.
How You are connecting to Oracle database and what is meant by connect string.
What is meant by partition view.
What are various triggers that You have extensively used in your application.
What is Dynamic SQL.
What are the backup procedures for oracle.
What is meant by 2 phase commit.
Which case designer you have used and what was the version of it.
what is SQL loader.
What are the various security provided by oracle.
What is difference between content and stacked canvas
Database triggers call database procedures and vice versa.
You will define and raise your own exceptions.
many error codes you can use to have your own error messages.

DBA RESPONSIBALITIES :
1)Install & upgrade the ORACLE7 server and application tools
2)Create primary database storage structures and primary objects
3)Allocate system storage and plan future storage requirements for the database system.
4)Modify the database structure
5)Enrol Users.
6)Control and monitor user access to the database
7)Backup and recover the database
8)Maintain system security.
9)Monitor and optimize database performance.

ORACLE ARCHITECTURE

Consists of System Global Area, Background processes, Database files, Redolog files, control files & Parameter
files

I. SYSTEM GLOBAL AREA consists of Shared Pool (Shared SQL Area), Database buffer Cache, Redolog
buffer.
Shared Pool consists of Library cache & Data Dictionary cache, Parsed form of the SQL or PL/SQL statements,
Execution Plan for SQL and PL/SQL statements, Data dictionary cache containing rows of datadictionary
information.
Three Phases of processing SQL statements.
I. PARSE
:Checks syntax, Queries the datadictionary for object resolution, security privileges and the most
effective search path, Determines the parse tree or Execution Plan.
II. EXECUTE :Applies parse tree to data buffers, performs physical reads or logical read writes.
III. FETCH
:Retrieves row of data for a select statement.
Database buffer Cache : The database buffer cache hold copies of data blocks read from disk, shared by all
ORACLE user processes concurrently connected to the instance, the size is determined by the parameter
DB_BLOCK_SIZE.
The number of block cached in memory is determined by the parameter
DB_BLOCK_BUFFERS.
REDOLOG Buffer
:The redo log buffer is a circular buffer containing information about changes made to the
database. Stores all changes made to the database in the redo entries of redo log buffer, used to reconstruct or
rollback changes made to the database when recovery is necessary. The size of redo log buffer is determined by the
parameter
LOG_BUFFER.

II.

BACKGROUND PROCESSES :

1)DBWR

:Modified data blocks are written back to disk by DBWR process.

2)User

:A user process is created when a user runs an application program

3)LGWR
:Oracle records all changes made to the database in the redolog buffer. LGWR process writes the
information in the redo log buffer to disk when a commit occurs, the redo log buffer pool reaches one third full
threshold, the DBWR needs to clean the buffer blocks for a checkpoint or a time out(3 sec) occurs.
4)ARCH
become full.

:The Archiver process copies online redo log files to a designated storage device once they

5)PMON
:The Process Monitor cleans up abnormally terminated connections, Roll back uncommitted
transactions, Releases locks held by terminated process. Free SGA resources allocated to the failed processes,
Detects deadlocks and automatically resolves by rolling back the transaction.
6)SMON

:Performs automatic instance recovery, Reclaims sort table space.

7)RECO

:The Recoverer process resolves failures involving a distributed transaction.

8)LCkn :The Lock process performs inter instance locking in a parallel server system.

9)Dnnn :The Dispatcher process gets the request from user processes and puts in request que in SGA, & also gets
the response from response que in SGA and passes back to user process.
10)LISTENER :The listener process identifies the path and protocol in MTS environment.
11)Server
:A server process communicates with user process and SGA. & datafiles. Parses and executes SQL
statements, Reads datablock from disk into the shared database buffers of the SGA, returns the results of SQL
statements to the userprocesses.
12)CKPT
:process updates headers of data and control files after check point has been completed, more
frequent checkpoint will reduce the time necessary for recovering from instance failure, at the expense of
performance, the check point process is enabled through the parameter CHECKPOINT_PROCESS.
13)SNPn

Snapshot refresher

SGA
:Every time ORACLE is started, the SGA is allocated and the ORACLE background processes are started.
The combination of memory buffers and background processes is called an ORACLE instance
ORACLE database is composed of Control files, and the database and redo log files named in control files.
III
Data files
: Contain all the database data, logical structures such as tables and indexes, are
physically stored in the datafiles.
Redolog files
:Transaction logs record all changes made to the database and are used for data recovery, if the
redo log files are mirrored, the same redolog information is written to multiple online redo log files. The redo log
files are written to in a circular fashion, there must be at least two redo log groups.
Log Switches
:A log switch occurs when ORACLE switches from one relog to another, when LGWR has filled
one log file group, A log switch can be forced by a DBA when current redo log needs to be archived ( ALTER
SYSTEM SWITCH LOGFILE), At a log switch the current redo log is assigned a log sequence number that
identifies the information stored in that redo log and is also used for synchronization, A checkpoint automatically
occurs at logswitch.
CHECKPOINT :During a check point DBWR writes all dirty buffer in the database buffer cache to disk,
guaranteeing that all data blocks are modified since the Previous checkpoint are actually written to disk.
A Check point occurs at every log switch, a specified number of seconds after the last database checkpoint, when a
predetermined number of redo log blocks have been written to disk since the last check point, at instance shutdown,
when forced by DBA (ALTER SYSTEM CHECKPOINT) , when a table space is taken offline.
During a check point and after the log switch LGWR will update the headers of database and control files, unless
check point process has been started, The parameter LOG_CHECKPOINT_TIMEOUT determines the interval of
time after which another check point occurs, The parameter LOG_CHECKPOINT_INTERVAL determines the
number of newly filled redo log file blocks needed to initiate a checkpoint.
CONTROL FILES
:The control file is a small binary file that describes the structure of the database, All
necessary database files and log files are identified by the control files, the name of the database is stored in the
control file, the control file is required to open and access the database, synchronization information needed for
recovery is stored inside the control file. It is advised to have minimum of two control files on different disks. The
parameter CONTROL_FILES identifies the Control files. Parameter file points to control file, Control file points to
redo log files and database files.
STARTUP STEPS

1)The Init.ora is read, the SGA is created, the background processes are started and the instance is started.

2)The control file is read and the database is mounted.


3)Rolling forward occurs to recover the data that has not been recovered in the database files, yet has been recorded
in the online redo log, including the contents of rollback segments.
4)Transaction that have been explicitly rolled back or have not been committed are rolled back, as indicated by
rollback segments regenerated in prior step.
5)Any resources held by pending transactions at the time of failure are released.
6)Any pending distributed transactions are resolved undergoing a two phase commit at the time of instance failure.
7)Once the SMON processes has synchronzied the database and all the outstanding information in the redo log files
have been applied to all the data files, the database is open for users to log into the database.

MULTI-THREADED SERVER ARCHITECTUE.


Uses of Multithreaded server
1.
2.
3.
4.
5.

Reduce the number of processes running against instance.


Increase the number of possible users.
Achieve load balancing(Server start and terminate automatically)
Reduce the number of idle server processes
Reduce memory usage and system overhead.

Connecting in MULTI-THREADED SERVER ARCHITECTUE.


The listener processes waits for connection requests from user processes, then determines if each user processes can
use a shared server process.
When the user can use shared server, the listener gives the user process the address of dispatcher process.
When the user process requests for dedicated server, the listener creates dedicated server process ad connects user
process to it.

PROCESSING A REQUEST
A user send a request to its dispatcher.
The dispatcher places the request into the request queue in the SGA.
A shared server picks up the request from the request queue and processes the request.
The shared server places the response on the calling dispatchers response queue
The dispatcher returns the response to the user.
Steps to configure Multi-threaded Server.
1. Configure and start the listener process.
2. Specify the dispatcher service name
3. Specify the initial number of dispatchers
4. Specify the maximum number of dispatchers
5. Specify the initial number of shared servers
6. specify the maximum number of shared servers
In the parameter file following parameter are to be set.
MTS_LISTENER_ADDRESS
:Address of listener process
(address=(protocol=tcp)(host=erseq5) (PORT=7000))
MTS_SERVICE
;Name of the service
MTS_DISPATCHERS
:Initial number of dispatcher process
MTS_MAX_DISPATCHERS
:Maximum number of dispatcher process
MTS_SERVERS
:Initial number of shared servers
MTS_MAX_SERVERS
:Maximum number of shared servers.

Steps to start listener process .


1)Login as ORACLE7 with the password larry
2)Go to $ORACLE_HOME/rdbms/admin dir

3)$lsnrctl start (this command will start the listener process, it is advised to start the listener process before the
starting database).
On the client end connect string has to be specified in the file tnsnames.ora
Colin = (Description = (Address=(Protocol=TCP) (Host=erseq5) (PORT=7000) (CONNECT_DATA=(SID=prod)))
$sqlplus scott/tiger@colin

DATABASE STORAGE
TERM

DEFINITION

BLOCK

:Multiple Physical file blocks allocated from an existing data file

EXTENT

:A set of contiguous database blocks

SEGMENT
tablespace

:A set of one or more extents that contains all the data for a specific structure within a

TABLESPACE :A logical repository of physically grouped data


FILE

:A physical data file belonging to a single tablespace

DATABASE

:A logical collection of shared data stored in tablespaces.

An ORACLE datablock is the smallest unit of I/O used by the database also called logical blocks and ORACLE
blocks which corresponds to one or more physical blocks on disk. The size is determined upon database creation by
initialization parameter DB_BLOCK_SIZE which is constant throughout all datafiles. Size also determines the size
of each database buffer in SGA. The block size cannot be changed after database creation except by recreating the
database. The block size should be equal to the size of O.S block size or more that that, typically 2K or 4K bytes.
PARTS OF DATABASE BLOCK
HEADER
:Contain general block information, such as the block address, and the segment type. On the
average, the fixed and variable portions of the block total 85 to 100 bytes.
TABLE DIRECTORY

:Stores information about the tables in the cluster and is used with clustered segments.

ROW DIRECTORY
overhead per row.

:Contains row information about the actual rows in the block. Allow two bytes of

FREE SPACE

:Consists of set of bytes in the block that is still available for insert, or update space requirements.

ROW DATA

:Stores table or index data.

Block free space utilization parameters.


PCTFREE
PCTUSED
INITTRANS
MAXTRANS
PCTFREE
:Set the percentage of block to be reserved (Kept free) for possible updates to rows that are already
contained in that block with the PCTFREE parameter.
PCTFREE sets the percentage of usable block space to be reserved during row insertion for possible updates to rows
contained in that block.
After PCTFREE is met, the block is considered full, and is not available for inserts of new rows.
Space remaining in block after PCTFREE quota is reached is reserved for update commands on rows within the
block.

The PCTFREE parameter can also be specified when creating or altering indexes.
Increasing PCTFREE reduces the occurrence of rowchaining and row migration. A PCTFREE set too low for a
given table may result in row migration.

ROW CHAINING & ROW MIGRATION.


Chaining occurs with large rows that contain long columns when all the data for a row in a table can not fit in the
same block. The data for the row is stored in a chain of data blocks.
Migration occurs if a row in a data block is updated so that the overall row length increases and the blocks free
space has been completely filled. The data for the row is migrated to a new datablock, assuming the entire row can
fit in a new block.
Performance is affected due to rowchaining and row migration, because during I/O ORACLE must scan more than
one data block to retrieve the information for the row.
TO RESOLVE ROW CHAINING AND ROW MIGRATION.
1)Examine the extent of chaining or migrating with the ANALYZE command.
2)Alter PCTFREE for the object.
3)export, drop and import the object.
LOW PCTFREE
:Allows inserts to fill blocks more frequently, can cause row migration and row chaining,
increases processing costs if ORACLE must frequently reorganize the blocks.
HIGHER PCTFREE :Reserves more room for future updates, may require more block to store the data, low
processing costs, reduces the need to row chaining and row migration.
PCTUSED
:Set PCTUSED to allow a block to be reconsidered for the insertion of new rows. New rows are
inserted as long as the block is on the free list. A block is removed from the free list upon reaching the PCTFREE
threshold.
PCTUSED is the threshold for determining when the block is available for row insertion.
When the percentage of block being used falls below PCTUSED either through row deletion or updates reducing
column storage, the block is again available for insertion of new rows.
The system default for PCTUSED is 40
High delete activity may result in block fragmentation.
BLOCK FRAGMENTATION
:Free space is not contiguously available due to high delete activity, low
PCTUSED setting.
RESOLVE BLOCK FRAGMENTATION :ORACLE will perform a memory operation to condense the data in the
block together under special cirucmstances.
Otherwise, export, drop, and import the object.
Modify PCTUSED to a more appropriate setting.
LOWER PCTUSED
HIGHER PCTUSED

:Reduces processing costs because blocks are not often free, increases unused space.
:Increases processing costs because blocks may often become free, improves space usage.

INITTRANS
: is the initial number of transaction entries, for concurrent transactions, that are allocated in each
block header when block is allocated (default is 1, minimum 1, maximum 255). Each transaction entry is 23 bytes
in length.
MAXTRANS :is the maximum number of concurrent transaction that a block will support (default 255,
minimum 1, maximum 255)
EXTENTS
:
An extent is a set of contiguous blocks allocated to a segment, when a database object grows, space is
allocated to it.

Each segment in a database created with at least one extent to hold its data, Rollback segment, however always have
at least two extents.
The first extent is called the segments INITAL extent.
Subsequent extents are called the segments NEXT extent.
An object will only allocate a new extent if all of its currently allocated extents are already used.
Frequently de-allocation of extents can lead to fragmented physical data files.
Specified storage parameters:
INITIAL

:Size in bytes of the first extent allocated to a segment. Default is the equivalent of 5 data blocks.

NEXT
data blocks.

:Size in bytes of the next incremental extent allocated to a segment. Default is the equivalent of 5

MAXEXTENTS :Total number of extents that can ever be allocated for the segments. The maximum depends upon
the ORACLE block size, default is 121.
MINEXTENTS :Total number of extents to be allocated when the segment is created. Default is one extent.
PCTINCREASE:Percent by which each incremental extent grows over the last incremental extent allocated.
Default is 50 percent.
OPTIMAL

:Specifies the optimal size in bytes for a rollback segment. Default is null.

FREELISTS

:Number of lists of free blocks kept for inserts into table.

Set the storage parameter for the following objects :


TABLE, CLUSTER, INDEX, ROLLBACK SEGMENT, TABLESPACE
Rules of precedence :
Any storage parameter specified at the object level overrides the corresponding option set at the tablespace level.
When storage parameter are not explicitly set at the object level, they default to those at the tablespace level.
When storage parameters are not explicitly set at the tablespace level, ORACLE system defaults apply.
If storage parameter are altered, the new option apply only to the extents not yet allocated.
Optimal is only specified for rollback segments.
Uncontrolled extent allocation can cause performance degradation due to potentially excessive physical I/O
operation and operating system file fragmentation. Fragmentation can be reduced by fitting a segment into the
INITIAL extent, and setting PCTINCREASE appropriately to enlarge incremental extents.
SEGMENTS

A Segments is a set of one or more extents that contain all the data for a specific type of logical storage structure
within a tablespace.
A segment is a logical structure that can be created, will occupy storage, and can grow. Segments cannot span
tablespaces. An extent is a set of contiguous database blocks. The storage parameters for temporary segments
always use the default storage parameters set for the associated tablespace , they can never be set explicitly.
DATA SEGMENT
:A collection of extents that holds all the data for a table or a cluster. When a table is
created in table space data segment gets created.
Ex. Create Table tablename ( colname datatype)
PCTFREE 5 PCTUSED 65

STORAGE(
INITIAL
5M
NEXT
5M
PCTINCREASE
0
MINEXTENTS
1
MAXEXTENTS
121)
TABLESPACE tablespacename;

INDEX SEGMENT
:A collection of extents that holds all of the index data for search optimization on large
tables and clusters. If an index is created on a table, an index segment is created for each index.
Ex. Create Index indexname on tablename (colname)
STORAGE (INITIAL 500K NEXT 500K PCTINCREASE 0)
TABLESPACE tablespacename;
TEMPORARY SEGMENT
:A collection of extents that holds data belonging to temporary tables created
during a sort operation. Temporary segments provide workspace for the RDBMS to sort and join tables while
performing complex searches, reclaimed at the end of the transaction (SMON process), space allocation determined
by default storage of its tablespace, not protected by redolog.
ROLLBACK SEGMENT
:A collection of extents that hold rollback data for rollback, read-consistency or
recovery. Rollback segment entries are written in circular fashion for rollback, read consistency and recovery.
Consists of several rollback entries from multiple transactions.
Ex. SQL >CREATE PUBLIC ROLLBACK SEGMENT rbs01
TABLESPACE rbs
STORAGE(INITIAL 10K NEXT 10K OPTIMAL 20K MAXEXTENTS 121);
After creating set the rollback segment online.
SQL >ALTER ROLLBACK SEGMENT rbs01 ONLINE;
BOOTSTRAP SEGMENT
;An extent that contains dictionary definitions for dictionary tables to be loaded
when the database is opened. Requires no attention on the part of the Database storage Administrator
The bootstrap segment contains data dictionary tables to be loaded when the database is opened. It cannot be read,
modified, or dropped. Exists in system tablespace and is owned by the user sys. Usually needs less than 50
ORACLE BLOCKS.
TABLESPACES & DATAFILES
Data in an ORACLE database is logically stored in tablespaces and physically stored in database files.
The ORACLE database can be logically divided into separate tablespaces. The system tablespace must exist in
order for the database to run. Tablespaces are designated to contain sever database segments.
Each tablespaces contains one or more operating system files.
Tablespace can be brought online while the database is running.
Tablespace can be taken offline except the system tablespace, leaving database running.
Objects created in a tablespace can never be allocated space outside of their original tablespace.
TABLESPACE USAGES;
Control space allocation and assign space quotas to users.
Control availability of data by taking individual tablespaces online or offline.
Distribute data storage across devices to improve I/O performance and reduce I/O contention against a single disk.
Perform partial backup and partial recovery operations.

IMPORTANT DATA DICTIONARY VIEWS.


USER/DBA_EXTENTS
USER/DBA_FREE_SPACE
USER/DBA_SEGMENTS
DBA_TABLESPACES
DBA_DATA_FILES
1)To view tablespaces and status
SQL>SELECT TABLE_SPACE_NAME, STATUS FROM DBA_TABLESPACES;
2)To view datafiles
SQL>SELECT FILE_NAME, FILE_ID, TABLESPACE_NAME, BYTES FROM DBA_DATA_FILES;
3)To view extents of free space in each tablespace
SQL>SELECT * FROM DBA_FREE_SPACE ORDER BY FILE_ID, BLOCK_ID;
4)To view general information about all segments in the database.
SQL>SELECT OWNER, SEGMENT_NAME, EXTENTS, MAX_EXTENTS FROM DBA_SEGMENTS
ORDER BY 1, 2;
1. How to find out the Duplicate Rows in an Existing Table
(Using SQL)?
Ans=> select * from emp a
where a.rowid = (select max(b.rowid) from emp b
where b.empno = a.empno)
This will display rows which are having duplicates.
2. Modification in a Package Body, will it affect Package Spec?
Ans=> No, It will not affect the Package Specifications as long as the
parameters and names are not changed.
3. A view is created through multiple table. If you change the data in
the table of view, Will it affect the view.
Ans=> No, It will not affect the View. If the change is in the Structure of
of any table or renaming or dropping of tables will change the view
status.
4. What are type of the DB Triggers.
Ans=> There are 12 Database Triggers. These can be mainly classified into two
types such as Statement wise, and Each Row wise. and Each one will have
one Before and one After Trigger.
5. Difference between On-Error and On-Message Triggers?
Ans=> An On-Error trigger fires whenever Oracle Forms would normally cause
an error message to display.
An On-Message trigger Fires whenever Oracle Forms would normally cause
a message to display.
So the On- Error will fire only when the Error Message to be displayed

where as the On-Message will fire for all the message commands including
the error messages.
Generally an On-Message trigger is used for the following purposes:

to trap and respond to an informative message


to replace a standard informative message with a custom message
to exclude an inappropriate message

where as an On-Error trigger is used for

to trap and recover from an error

to replace a standard error message with a custom message


6. Difference between Oracle 6.0 and Oracle 7.0
Ans=> There are lot of differences between 6 and 7
I am listing whatever on hand i have.
0) There are some new datatypes in Ver 7.0 such as
Variable Length VARCHAR2,
i) There are no Constraints such as referential Integrity, Primary Key.
ii)There are no Stored Procedures
iii)There are no Database Triggers
iv) There is no Shared pool of parsed SQL in 6.0
v) There is no Packages funda in v 6.0
vi) There are no Hinting to Optimize such as in Sql Execution
vii) In ver 6.0 only dedicated server is available whereas in ver 7.0
there are several types of servers are available such as
- Dedicated Server
- Multi Threaded Server
viii) There is no concept of Distributed Databases in ver 6.0 whereas
this is supported in ver 7.0 in the form of two phase commit.
ix) There were only Rule based optimisation in Ver 6.0 whereas in ver 7.0
both Rule Based and Cost Based Optimization is supported. In ver 7.0
By default Cost based optimization is adopted.
x) There is an Archieve Log facility in Ver 7.0
xi) Snapshots are not available in ver 6.0.
xii) There are new commands such as ANALYSE and TRUNCATE
7. How do you check 1-1 relationship existing between two tables?
Ans=> Raghu This Question is little vague, If it is to find out the Relation
ship between two Blocks in a Form, Then using the follwing command you
will know.
If you still insist on tables, You can select from the user_constraints
view to find out the Foriegn Key constraint.
8. When you create Master-Detail Blocks, What are all triggers created?
Ans=> There are three triggers will be created by default such as
On-Check-Delete-Master (Block Level)
On-Clear-Details (Form Level)
On-Populate-Details
(Block Level)

and it also creates following procedures to coordinate the m/d


Check_package_failure
Clear_all_master_details
Query_master_details
9. How do you join two tables ?
Ans=> This Question is also either vague or silly?
But any way i will try to answer it.
By using the Where Clause of the SELECT Statement we can Join the Tables
Following are the types of Joins such as Equi Join, Self Join and Outer Join
10.How do you avoid using indexes?
Ans=> There are two ways by which we can avoid using indexes by Oracle.
- By Hinting the SQL Statement we can instruct Oracle to use Full Table
Scan
- By using some function or calculation in the Select Statement Oracle
will avoid using Indexes. For e.g.,
Select * from emp where 1 * empno = empno;

TELEPHONIC INTERVIEW DETAILS


Venue : ODSI
Date : 25-Sep-96
Interviewers : Molly (from OCS)
Interviewee : Shridhar Kamat
Type: Skill matrix non-technical reseller interview.
(After initial introduction)
1) You have any problem in working anywhere in states?
A) No. I dont mind.
2) Are you on the project or are you available immediately?
A) I am available immediately?
3) Since how long you are working on Oracle?
A) Since November 92
4) OK! That means for about 4.0 years. And in Forms 4.0?
A) About 7 months.
5) Forms 3.0?
A) About 10 months
6) Roughly how many forms you developed in 3.0 and 4.0

A) I dont remember from top of my head right now but somewhere around 25.
7) In both?
A) No only in 4.0. Developed around another 15-20 in 3.0.
8) So roughly about 40. How about reports. You worked on both 2.0 and 1.1 right?
A) Right.
9) How many reports you developed in each of them?
A) Around 40 in reports 2.0 and 20 in 1.1.
10) How many of them were complex?
A) About 5 in 2.0 and in 1.1 most of them were simple.
11) OK so I will write about 10 in both of them. On the level of 1..5, 1 is trained, 2 is modest, 3 is average, 4 is
proficient and 5 is expert., how will you rate yourself in forms 4.0?
A) I will rate myself 4.
12) In forms 3.0?
A) Forms 3.0 also 4.
13) In reports 2.0 and 1.1
A) In reports 2.0 4 and 1.1 I rate myself 3.
14) How long you are working in SQL*Plus?
A) About 4 years
15) And in PL/SQL?
A) About three and half years.
16) How you rate your skills in these Oracle Tools?
A) In SQL*Plus, PL/SQL and SQL*Loader I rate myself 4.
17) Have you worked on Pro*C?
A) Not on any live projects but I have worked on C
18) How long you are working in C?
A) About 4-5 months.
19) How long you are working in Oracle Financials?
A) For about one and half years.
20) Which all modules you worked on Oracle Financials?
A) Mainly Accounts Payable.
21) How long? For one and half years?
A) It is difficult to say but for about one year because I worked on other modules also interactively?
22) Which other modules you have worked and approximately how long?
A) In Purchasing for 2 months and General Ledger for about 2-3 months.
23) Have you worked on Accounts Receivables? Or Manufacturing like Oracle MRP or BOM?
A) No.
24) Have you worked as a DBA?
A) No.

25) Are you familiar with Analysis or Design?


A) Yes, as a matter of fact I did the table design in one of my projects in Sun Microsystems.
26) Have you worked in any interface projects?
A) Yes. In one of my projects at Starkey Laboratories I worked on interface mapping to change the data from
Legacy system into oracle Financials tables with help of mapping the GL code combinations. However, all the
specifications were given. I have not worked in functional part of it, I was working in the technical side,
working on forms and reports and PL/SQL
27) OK! So you rate yourself as a technical and not a functional person. Have you worked on AOL?
A) Yes. I worked on AOL mainly to implement reports in Oracle Financials and creating or revoking a user or its
user responsibilities.
28) How would you rate yourself in AOL?
A) About 3.
29) OK! I will get back to you or Manoj soon. Thanks!
A) Thanks a lot
Interview Transcript
Interviewer : John (Quantum Corp.)
Interviewee : R.Poominathan
Date
: 09/19/96
Duration : 30 mins.
J : What is your experience on ORACLE ?
P : I have approximately 5 years experience.
J : What is the procedure that you followed in tuning ?
P : First I will find the cause of poor performance. Depends on the cause I will tune SQL,
Memory and I/O.
J : What is the first step that you do when there is a performance problem with SQL ?
P : I will generate trace file using the latest statistics to monitor the SQL execution path.
J : How will you say whether a SQL statement is well tuned ?
P : By seeing the execution path of SQL one can conclude whether a SQL is tuned.
J : How to generate output using the trace files ?
P : I use TKPROF utility to generate the formatted output from trace files.
J : What is the content of TKPROF output ?
P : It will show the execution path it followed like index scan or full scan was used for retrieving
data from a table.
J : How many years have you worked as a DBA ?
P : About 2.5 years I have worked as a DBA.
J : Give me an example where you tuned the badly performing SQL statement ?
P : I gave an example of SQL statement using internal sort/merge and how it was tuned to avoid
internal sort.
J : How do you use cost based optimizer?
P : Statistics must be generated for the objects using cost based optimizer. If it is available,

Oracle by default use the cost based optimization for finding the best execution path.
J : How do you go about tuning init.ora parameters ?
P : Monitoring the contention level of objects like database buffers, library cache, redo log buffer
over a period of time, we can alter the init.ora parameters for better performance.
J : How to identify badly written reports without using trace ?
P : Using v$sqlarea, one can monitor the performance of sql statements used in the reports.
J : Okay. Thank you. bye.
P : Okay. Thanks bye bye.

Mock Interview Transcript

Date:
Venue :
Interviewee
Interviewer

:
24th Sep 1996
European Operations
:
T.Geresh and Rajkumar
:
Oracle Group

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)
40)

What are the multithreaded server and how it is different from dedicated server .
What are the new features incorporated in ORACLE 7.2 version.
What are the various difference between ORACLE 6.0 ORCALE7.0.
How many types of triggers U have used in your application.
What are the difference between WHEN-VALIDATE-ITEM and POST-CHANGE trigger.
What is Record group and what are the advantages of having it.
What is the differences between Tlist,ComboBox and PopList properties of list items.
What are the differences between copying and referencing an object.
What is MDI Window.
What is the procedure to call a Microsoft Application from forms 4.5.
What is VBX controls and how it helps to build an application in Forms 4.5.
How Parameters will be passed to other Oracle tools.
What kind of quality management Sonata is having.
What is meant by ISO9000 an dwhat are the advantage to have it.
What do you mean by debugger in Forms 4.5
While debugging we can change the script or not.
Can We have an OLE server for Oracle application.
are the various variables in Proc and how we are declaring it.
What is meant by Indicator variable in Pro*C
What is difference between SQLCA and ORACA.
How You are trapping errors in Pro*C program
What is meant by UserExits and how we You will call it from your forms 4.5 application.
What is difference between UserExits and Pro*C program
What are the various triggers that Reports 2.5 supports.
What is icon.
How many(minimum) groups are required to prepare a Matrix Report.
What do you mean by bind parameter and lexical parameter.
What are the various difference in UNIX and WINDOWS95 Operating systems.
What are the various differences in Forms 3.0 and Forms 4.5
Can I have a HTML document from Forms 45 application.
What do you mean by activation style property of an OLE object.
What is difference in Object embedding and object Linking.
What are the situations in which we can go for embedding and in which we can go for Linking.
How You are connecting to Oracle database and what is meant by connect string.
What are the difference between Post-fetch and Post-Query trigger and when they will fire.
What is meant by partition view.
What are various triggers that You have extensively used in your application.
What is difference between following built-ins
Create_group_with_query and Populate_group_with_query.
What is Dynamic SQL.

41)
42)
43)
44)
45)

How you can change menu type property


what are the backup procedures for oracle.
What is meant by 2 phase commit.
Which case designer you have used and what was the version of it.
what is SQL loader.

46)
47)
48)
49)
50)
51)
52)
53)
54)
55)
56)
57)
58)
59)
60)

What are the various security provided by oracle.


What is difference between content and stacked canvas
Can you tell something about TOOLBAR.
What are the sequence of commit processing triggers
can you create dynamic LOV.
How you will control transaction in MDI.
what do you mean by session in MDI.
Database triggers call database procedures and vice versa.
do you use global variables and parameters.
you will define and raise your own exceptions.
many error codes you can use to have your own error messages.
Can you change the retrieved value of reports.
What is an anchor in Reports 2.5.
What is the trigger that fires while navigating between the form.
Can you tell something about window based triggers.

DBA - Interview Transcripts (telephonic)


Interviewer : Hiten (Visualtech consulting inc.)
Interviewee : R.Poominathan
Date
: Sep.16,1996.
Duration : 15 mins.
H : How many years experience do you have in DBA ?
P : It is about 2.5 years.
H : What was your job as DBA ?
P : Installation of Oracle, creating logical structures, database design, formulating backup and
recovery procedure, maintaining database security by defining roles and privileges and performance tuning.
H : What is the purpose of using SQL*Net ?
P : SQL*Net is required to connect client and server in the C/S architecture. It is also used to configure multithreaded architecture.
H : What is the use of having multi-threaded architecture ?
P : Multi-threaded architecture basically reduces the number of servers accessing ORACLE database. As one server
can handle the requests of many users, number of processes accessing the database will be greatly reduced. In this
way, it contributes to the over all system performance.
H : What is SGA ?
P : System Global area is a memory structure used to act as an interface for accessing the Oracle database. It
contains shared pool (Library cache & Data dictionary cache), Database buffer cache, redo log buffer. It also caches
rollback segment. Private SQL area is also a part of shared pool if it is a multi-threaded architecture.
H : What is the tool that used for monitoring hardware I/O ?
P : I didnt use any such tool.
H : Have you implemented Distributed data processing system?
P : I didnt get a chance to work on Distributed data processing system, I know how to configure Distributed
databases and network access methodologies.
H : What is striped table ?
P : Striped table is one whose data is spread among more than one disks to improve access performance.
H : What are the disadvantages with striped table ?
P : If one of the disk holding table data crashes, the table cannot be accessed.
H : Have you used striped tables in your application ? Tell me other disadvantages.
P : There was no requirement for using striped tables in my application. I have no idea about other disadvantages.
H : What is the functionality of LGWR ?
P : This background process is used to copy the data from log buffer to redo log file. If CKPT is not present, it does
the work of CKPT process, ie., it updates the headers of datafiles, controlfiles with the latest SCN (system change
number).
H : Ok. Bye.
P : Bye bye.

TELEPHONIC INTERVIEW DETAILS

Venue : ODSI
Date : 16-Sep-96
Interviewers : Sushil Kumar (from CST)
Interviewee : Shridhar Kamat
(After initial introduction)
1) Since how long you have been in Oracle Financials?
A) Since January 95 I am in Oracle Financials
2) Tell me about the projects you have done?
A) (Explained to him about the Custom Purchasing report for Honeywell, Interface mapping system for Starkey.
Interrupting)
3) So you have worked on Purchasing, Have you worked on GL?
A) I have worked on GL, Purchasing and AP modules?
4) Have you worked on FA (Fixed Assets)?
A) No.
5) That is fine. What all work you did in your projects?
A) Mainly I was involved in writing custom reports. I have also written some PL/SQL blocks. I was handling the
technical side. After creating reports I also implemented it using AOL in .. (Interrupting)
6) OK! My client Hemal may give you call today. Give me your residence number
A) (Gave him the residence number)
7) He has requirements in Denver and Omaha. He is also an Indian. He is staying here for almost 15-20 years. You
have an excellent communication skills. However, when you talk to him, talk in American accent so that he will
be thoroughly impressed. He may give a call as soon as he receives your resume. Then I will give you call
sometime in the evening. Are you available?
A) Yes. Certainly. I will be in the Office till 5.00 pm after that you can reach at my residence.
8) OK! Bye now.
A) Bye

DBA - Interview transcripts (telephonic)


Staff name : Poominathan. R
Interviewer : Anil Gupte (MCI Communications Inc.)
Date
: Sep.11,1996.
Duration : 25 mins.
A: Can you tell me something about you ?
P: I have 2.5 yrs. experience as Oracle DBA and approximately 5 yrs, on Oracle RDBMS. I have worked on Oracle
versions from 5.0 to 7.2. My overall experience in the S/W field is over 8 yrs.
I have worked on various platforms as PC, Mini computers and mainframe computers. Besides
administration of Oracle RDBMS, I have worked on other large databases in various capacities
from developer to project leader.
A: What was your role in BAYBIS ?
P: My role was DBA. I briefly told him about the nature of the application and the work I had done.
A: Were you involved in database modeling ?
P: Yes, I was involved in modeling and responsible for database schema creation for BAYBIS.
A: Have you done tuning in BAYBIS ?
P: Yes. At the design time itself, the database was designed with regard to performance aspects.
In production stage, the performance of the system was continuously monitored and corrective steps were taken to
give the best performance.
A: What are the init parameters that you tuned ?
P: I mentioned a few parameters such as database buffer cache, shared pool & log buffer.
A: What is the use of shared pool ?.
P: It has two parts Library cache and data dictionary. Library cache stores all SQL statements & stored procedures
issued by users. Data dictionary stores all oracle dictionary tables. Basically this pool is shared by all users
connected to the system. In multi-threaded architecture shared pool also stores private SQL area containing session
information.
A: Have you tuned database buffer cache ?
P: Yes, based on the usage of database buffer cache at peak hours, I tuned the size.
A: How did you arrive at the buffer cache size ?
P: We can make out from the hit ratio on DBS buffer cache.
A: How hit ratio is used to determine ?
P: If the hit ratio is near 100%, one can conclude that the buffer cache size is sufficient. If the hit ratio is low,
contention for buffer cache can be reduced by increasing the buffer cache size.
A: How do you arrive at the optimum size of buffer cache ?
P: Before increasing the size of buffer cache, one can monitor the effect of increased size by using two dynamic
tables, named, X$KB By comparing the hit ratio manipulated for various buffer cache sizes, one can arrive at
optimum size which will contain blocks no more than required.
A: Have you worked on Distributed data processing ?
P: I have worked on multi-threaded system with SQL*Net 2.0. I configured parameters for network connection. For
Distributed, we need to create database link to connect to the target database.
A: How will you handle if one site has problem in transaction ? How will you resolve it ?.

P: There is a concept called two-phase commit. In the first phase, the server makes sure that all sites are available for
transaction. If all are available, then the commit/rollback phase occurs. If any transaction is held up due to
unavailability of resources in the target site, the transaction is named in-doubt transaction and data is stored in the
data dictionary of the target site. This will be later committed/rolled back by RECO background process. DBA can
also see the status of in-doubt transaction and based on the comment given along with commit/rollback, he can take
commit/rollback manually.
A: what was your backup strategy ?
P: Everyday I used to take hot backup along with archived redo logs. Besides, I used to take ascii text backup for a
few important tables using exp command.
A: Have you done database recovery ?
P: Yes. 5 times I have recovered database, mostly data files using archived redo logs and old data files.
A: Have you done trigger based applications ?
P: Yes, I have done many applications using DBS triggers. If you are specific, I can tell you more.
A: Have you handled DML statements using triggers ?
P: Yes. I mentioned about the use of DBS triggers in one of my application.
A: How would you handle duplicate rows in a table ? I want to find out the duplicate rows. How to go about it using
primary key?
P: When one uses alter table command with exceptions clause, the duplicate row information will go into a predefined table structure.
A: Its okay with you. Do you have any questions ?
P: Yes, I want to know more about the client and nature of application.
A: He told about the clients business and the type of applications using the database.
P: Okay. Thanks. No more questions.
A: Okay. We will call you back. Thanks. Bye.
P: Thanks. Bye.

PERSONAL INTERVIEW DETAILS


Venue : Santa Clara, CA
Date : 05-Sep-96
Interviewers : Sharie Lee and Ming from Rational Software
Interviewee : Shridhar Kamat
First, I was introduced to Sharie who is the project manager.
1) Are you going to work here on a full time basis?
A) (Thinking that she meant full time or part time) Yes, but what is meant by full time basis.
2) I mean to say that are you coming here for a permanent position?
A) No, I came here as a contractor through my company ODSi.
3) Actually, this requirement is for a permanent position, but if we cannot find anybody for permanent position
then I will have to convince my boss that we may have to go for contractor as we could not get anybody for
permanent position and since we are in crises. Do you know about our company?
A) A very little.
4) Ok let me explain about our company in brief.
(Talked for about half an hour about the Rational Software. While concluding)
5) We have already implemented Accounts Payable, General Ledger, Purchasing. Currently we are working on
Order Entry and Accounts Receivable. Also, we will be implementing MRP and BOM in near future. However,
currently the requirement is for Order Entry and Accounts Receivable. Have you worked on in any of these
two?
A) No. But I have worked on Accounts Payable and General Ledger and Purchasing.. So it should not be a problem
for me as earlier I was not worked on these modules either.
6) How long you are in Oracle Financials?
A) I am in Oracle Financials for about last one and half years. First I was in Honeywell working on custom
purchasing reports which were developed in reports 2.0 then for Starkey labs on forms 4.0 and reports 2.0 and
again for Honeywell on year end reports on report 2.0. All of which were on Oracle Financials.
7) Tell me something about your last project, about year end reports you worked at Honeywell.
A) The reports which I developed for Honeywell were all year end reports and developed in reports 2.0 like
Invoices on Hold. I was the part of the IS team and we used to discus with the user about the reports. The user
used to give us the layout and should they require the report urgently they used to give me the specifications
also as to which table or column to pick. Otherwise, I used to find it out for myself . Then I used to design the
report and implement it in the Oracle Financials with the help of AOL.
8) Here there is nobody to give you specifications. So you may have to use manuals or contact Oracle. Tell me
about this report invoices on hold that you have developed.
A) Invoices on the hold report they were using to find out the total invoices which they have on hold along with the
invoice amount and vendor details. It uses the tables AP_INVOICES, AP_INVOICE_DISTRIBUTIONS,
PO_VENDORS, PO_VENDOR_SITES. I used to discus with the users about the requirements about their
reports and used to design and then implement in AOL.
9) What all things you did in AOL?
A) Mainly I implemented the reports using AOL. I also created or disabled users and their responsibilities using
the AOL.
10) Ok so mainly implementation of custom reports, menus and forms.
A) Yes, though I could not get a chance to implement menus and forms it should not be a problem as the most
difficult part is the implementation of reports as it require the report parameters also.

11) Have you defined any Flexfields?


A) Yes. As one of the requirement of the last project was to print the check reconciliation report, which they used
to do it on the weekly basis. One of the user used to run a SQL script by specifying the dates every week. Rather
than doing this, we defined one of the attribute of AP_CHECKS as R for reconciled and V for Void. Then we
run a SQL script for one time just to change the existing attribute to R or V and after that now it is running
every week marking R and V automatically as it is running through automatic job schedular called Autosys.
12) Have you implemented key code combinations? Have you been in before the implementation stage any time?
A) No. I was mostly in the post implementation stage only. Though I have not implemented any key code
combinations but my project at Starkey was of similar type. They had the old Legacy system which they want to
convert into Oracle Financials and eventually they wanted to discontinue with the Legacy system. Initially it
was decided to convert the data with SQL*Loader, since there were some systems which were still running in
the Legacy system because of which one person may be involved permanently for this job, rather than we
decided to develop a package with which they could change the data in the flat file format into temporary oracle
tables and then used to updated in the appropriate tables after verifying the data and mapped with the key code
combinations which they have already entered and validated at time of entering. However, this was not
implemented in Oracle Financials because it is going to be used till they transfer all the data from Legacy
system to Oracle tables.
13) Here we are also in the post implementation stage. We require someone for doing reports and assisting our
users. He should have good knowledge of the Oracle Tools and oracle modules particularly in Order Entry and
Accounts Receivable.
A) Yes, I am quite good in Oracle Tools such as Forms and reports 2.0 and also in SQL*Plus and PL/SQL. I am
also familiar with Forms 4.5 and Reports 2.5.
14) Thats great! Ming is our technical person who is a senior DBA here. He will ask you some technical questions.
You have any questions?
A) You said you have lot of projects here to be done. In case if I joined what would be your highest priority?
15) Well our priority is for Order Entry and Accounts Receivable. There are lots of reports to be finished first.
A) Which versions of forms and reports are you using right now?
16) As of now we do not want to modify Oracle Forms or Tables. But we are using forms 2.3 and SQL*Plus as
reports and for some complex reports we are using Reports 2.0. But we may go for Forms 4.5 and reports 2.5 if
we migrate from Oracle financials 10.5 to 10.6 in near future.
A) I am quite familiar with Forms 4.5 and Reports 2.0 though I havent worked on live projects.
17) Thats great! Any other questions?
A) No. Not at the moment.
18) Great I will call Ming now, he may ask you some technical questions. Thanks!
A) Thanks Sharie.
Then Sharie introduced me to Ming and she left.
1) How long you are in Financials?
A) About one and half years.
2) Have you worked on Accounts Receivable or Order Entry?
A) No. But I worked on Accounts Payable, General Ledger and Purchasing.
3) Allright. But our main requirement is for Order Entry and Receivable. Tell me about the project you have done.
A) (Explained about the Year end report project for Honeywell and Interface mapping project for Starkey)

4) Oh! We have Legacy system here and we have a similar requirement for transferring data from Legacy to
Oracle tables.
A) What hardware platform you are working on?
5) We have a Sun Sparc stations here.
A) Oh! I worked for Sun Microsystems on the same platform.
6) Thats great. Did you find any difference in HP and Sun sparc.
A) I was using pentium PCs which were connected to the HP unix boxes. But I liked Sun Sparcs better.
7) Yeah! We also have some emulators which connects to the Unix system. I think I am done. Do you have any
questions?
A) What would be your highest priority?
8) We have lot of things to be done in Order Entry and Accounts Receivables.
A) When do you think you can get back to me about this project?
9) Well, I have no authority. Sharie is my project manager and she will get back to you. Do you have any other
questions?
A) No.
10) Ok! Thanks!
A) Thanks a lot
Interview Transcript (Telephonic)
Staff Name : Poominathan R.
Interviewer : Charles Schwab Financial Systems.
Date
: August 29, 1996.
Duration : 30 mins.
C: What is your experience on handling large databases ?
P: I have handled a database of size 2GB.
C: Can you tell me the memory structure of your database ?
P : The SGA size was of 20MB. I mentioned the size of database buffer, shared pool and redo log buffer caches.
C: How do you arrive at the SGA size ?
P: It depends on various parameters such as number of concurrent transactions at the peak hours, transaction size,
number of applications using the database, number of other processes using the system resources and system
configuration (dedicated/multi-threaded). We have to also ensure that no paging and swapping occurs for SGA.
C: How do you find whether the allotted memory resources are sufficient ?
P: We have to look for possible contention for memeory structures. for example, if the hit ratio for database buffer
cache is low, we can allot more database buffers. Likewise, we can monitor the contention for library cache, redolog
buffers, redo log latches and rollback segments.
C: Can you tell me the procedure to monitor rollback contention ?
P: Well, Using V$waitstat and V$sysstat we can see the how many times a server process waited for a free extent in
rollback segment. If the percentage of waiting is more than one, we can conclude that the number of rollback
segments are insufficient.
C: Why is OPTIMAL parameter used in rollback segment ?

P: OPTIMAL parameter is used to bring back the rollback segment size if it were to grow due to long transactions.
To arrive at the OPTIMAL size, We can monitor using MONITOR ROLLBACK from SQL*DBA. Using this, we
can see how much space ever allocated for each rollback segment in bytes, Cumulative number of times a
transaction writing from one extent in a rollback segment to another existing extent and average number of bytes in
active extents in the rollback segment, measured over a period of time.
C: What was your backup strategy ?
P: Everyday I used to take hot backup which includes taking of relevent datafiles and then control file. Maintenance
of archived redologs, taking of cold backup and maintaining ASCII version of a few tables data were the other
backup strategies formulated.
C: Have you done recovery ?
P: Yes, I have done recovery a lot many times.
C: How do you recover if a datafile is lost/damaged ?
P: First step is to see whether the database is in archivemode. Secondly, Whether the disk containing the datafile is
accessible. If not accessible, rename the datafile to another usable disk. If archived, restore the affected datafile and
archived redologs from backups; if the damaged file was part of the system tablespace, keep the database mounted
and closed; use alter database option to do recovery, if it belongs to a non-system tablespace, use alter tablespace
command to recover it after taking the tablespace offline.
C: How to recover if the database was in noarchivemode ?
P: Only way to recover the database is to restore the most recent complete backup.
C: Have you done tuning ?
P: Yes, I have tuned both applications and database.
C: How to tune an application ?
P: First, we have to ensure that the application uses well tuned SQL statements. We can use SQL trace facility and
TKPROF to see the execution plan for SQL statement. If we are not satisfied with the current execution plan, use
EXPLAIN PLAN command to see the execution plan for different versions of the SQL statement. We can choose
the SQL statement which gives faster response time as well as consumes less system resources.
C: OK. All right. You will get a call tomorrow. Do have any question to ask ?
P: Yes, I want to know what will be my role in your project.
M: The system is under development. You will be involved at this stage itself. It is expected to go to production in
Jan97.

Anda mungkin juga menyukai