Wednesday 24 April 2013



IMPORTANT TOPICS TO BE PREPARED FOR FINAL EXAM
PHP

  • ·         Introduction to PHP
  • ·         PHP Static & Global Variable
  • ·         Get & Post method
  • ·         Conditional structure & looping structure
  • ·         Function : strlen, substr, sqrt, rand, getdate, include, require, fread, fopen, fseek
  • ·         What is Session ? Explain in detail.
  • ·         What is cookies ? Explain.
  • ·         Server variable
  • ·         Database connectivity with MySQL
  • ·         XML introduction
  • ·         AJAX introduction
  • ·         XMLHTTP request
  • ·         AJAX with MySQL database
  • ·         PHP Regular expression
  • ·         SMARTY introduction
  • ·         SMARTY variable

Monday 22 April 2013

Important questions for PG:
1. Explain SQL Command.
2. Explain GRANT and REVOKE command.
3. Deffrentiate SQL V/s. SQL *Plus
4. What is snapshot. Explain in detail.
5. Explain function of SQL.
6. Explain Operator.
7. What is normalization. Explain in detail.
8.What is cluster ? Explain in details.
9. Explain Group by and Having clause.
10.Explain transaction control command.
11. Explain Redo log file in detail.
12. What is table space? Explain its types.
13. What is backup and recovery?
14. What is trigger? Explain.
15. What is cursor? Explain its types.
16. Explain Instance Architecture.
17. What is stored procedure? Explain with example.
18. Explain import and export.
19. Write down Dr. E. F. Ted Codd Rule.
20. Justify Oracle as RDBMS.
Create following table
Table name : cust_master
Fields: cust_no (p), name, address, city

Table name : product_master
Fields: pro_no (p), p_name, qty, saleprice, costprice

Table name : purchase
Fields: cust_no (f), pro_no (f), p_qty, amount

and solve following queries:
(A) List the name of all customer who purchase "computer"
(B) List the p_name, p_qty and amount of all product purchase by "yash"
(C) List the non-moving product_name
(D) List the cust_name who purchase product of more thatn Rs. 1000
Solution:
create table cust_master
(cust_no varchar2(6) primary key,
name varchar2(25),
adderss varchar2(50),
city varchar2(15));

create table product_master
(pro_no varchar2(6) primary key,
p_name varchar2(15),
qty number(4),
saleprice number,
costprice number);

create table purchase
(cust_no varchar2(6) references cust_master(cust_no),
pro_no varchar2(6) references product_master(pro_no),
p_qty number(4),
amount number);


(A) List the name of all customer who purchase "computer"
      select name from cust_master where cust_no in (select cust_no from purchase where 
      pro_no in (select pro_no from product_master where     p_name="computer"))

(B) List the p_name, p_qty and amount of all product purchase by "yash"
      select d.p_name, p.p_qty, p.amount from product_master d, purchase p where
      p.pro_no=d.pro_no and p.cust_no in (select cust_no from cust_master where name="yash")

(C) List the non-moving product_name
      select p_name from product_master where pro_no not in (select distinct pro_no from 
      purchase)

(D) List the cust_name who purchase product of more thatn Rs. 1000

       select name from cust_master where cust_no in (select cust_no from purchase 
       where amount>1000)
Write an update trigger on client_master table. The system keep records are being updated. The old values of updated records should be added in the temp table.

Table :
temp
Fields: Client_no, name, operation, o_date, userid

SOLUTION:

CREATE OR REPLACE TRIGGER trg_client_master
BEFORE UPDATE ON client_master
FOR EACH ROW

BEGIN
   INSERT INTO TEMP VALUES(:old.Client_no, :old.name, 'UPDATE', sysdate, UID);
END;
/

Write a PL/SQL block to display following series

1 1 2 3 5 8 ..... N

DECLARE
term1 number;
term2 number;
term3 number;
n number;
BEGIN
  n:=&n;
  term1:=1;
  term2:=0;
  term3:=1;
  FOR i in 1..n
  LOOP
    dbms_output.put_line(term3||' ');
    term1:=term2;
    term2:=term3;
    term3:=term1+term2;
  END LOOP;
END;

Saturday 20 April 2013

Example of trigger:

There are three tables: studinfo, result and update_studinfo. If you insert data into studinfo then that data will be inserted into result with calculation automatically. If you update any data then new data will be inserted into result and old data will be inserted into update_studinfo. If you delete any data then old data will be inserted into update_studinfo table.

You can do that in following way:

create table studinfo
(studid varchar2(3),
name varchar2(15),
php number(3),
oracle number(3),
vb number(3));


create table result
(studid varchar2(3),
name varchar2(15),
php number(3),
oracle number(3),
vb number(3),
total number(3),
per number(6,2),
operation varchar2(7),
op_date date);


create table update_studinfo
(studid varchar2(3),
name varchar2(15),
php number(3),
oracle number(3),
vb number(3),
operation varchar2(7),
op_date date);


create or replace trigger trgstudinfo
before insert or update or delete
on studinfo
for each row
declare
total number;
per number(6,2);
begin
  if inserting then
    total:=:new.php+:new.oracle+:new.vb;
    per:=total/3;
    insert into result values(:new.studid,:new.name,:new.php,:new.oracle,:new.vb,total,per,'INSERT',sysdate);
  end if;

  if updating then
    total:=:new.php+:new.oracle+:new.vb;
    per:=total/3;
    insert into result values(:new.studid,:new.name,:new.php,:new.oracle,:new.vb,total,per,'UPDATE',sysdate);
    insert into update_studinfo values(:old.studid,:old.name,:old.php,:old.oracle,:old.vb,'UPDATE',sysdate);
  end if;

  if deleting then
     insert into update_studinfo values(:old.studid,:old.name,:old.php,:old.oracle,:old.vb,'DELETE',sysdate);   
  end if;

end;
/


Join

A join is a query that combines rows from two or more tables, views, or materialized views. Oracle Database performs a join whenever multiple tables appear in the FROM clause of the query.
Most join queries contain at least one join condition, either in the FROM clause or in the WHERE clause. The join condition compares two columns, each from a different table. To execute a join of three or more tables, Oracle first joins two of the tables based on the join condition comparing their columns and then joins the result to another table based on join conditions containing columns of the joined tables and the new table.
Equijoins:
An equijoin is a join with a join condition containing an equality operator(=). An equijoin combines rows that have equivalent values for the specified columns.
Ex. SELECT empno, ename, job, dname, loc FROM emp e, dept d WHERE e.deptno=d.deptno;

Non-Equijoins:
A join which contains an operator other than equal to ‘=’ in the joins condition.
Ex. SELECT empno, ename, job, dname, loc FROM emp e, dept d WHERE e.deptno>d.deptno;

Self Joins:
A self join is a join of a table to itself. This table appears twice in the FROM clause and is followed by the table aliases that qualify column names in the join condition.
Ex. SELECT e1.empno, e2.ename, e1.job, e2.deptno FROM emp e1, emp e2 WHERE e1.empno=e2.mgr;

Inner Joins:
An inner join (sometimes called a simple join) is a join of two or more tables that returns only those rows that satisfy the join condition.
Ex. SELECT empno, ename, job, dname, loc FROM emp INNER JOIN dept USING(deptno);

Outer Joins:
An outer join extends the result of a simple join. An outer join returns all rows that satisfy the join condition.
To write a query that performs an outer join of tables A and B and returns all rows from A (a left outer join), use the LEFT [OUTER] JOIN syntax in the FROM clause, or apply the outer join operator (+) to all columns of B in the join condition in the WHERE clause. For all rows in A that have no matching rows in B, Oracle Database returns null for any select list expressions containing columns of B.
Ex. SELECT empno, ename, job,dname,loc FROM emp e LEFT OUTER JOIN dept d
on(e.deptno=d.deptno);                  OR
SELECT empno, ename, job, dname, loc FROM emp e, dept d WHERE e.deptno=d.deptno(+);

To write a query that performs an outer join of tables A and B and returns all rows from B (a right outer join), use the RIGHT [OUTER] JOIN syntax in the FROM clause, or apply the outer join operator (+) to all columns of A in the join condition in the WHERE clause. For all rows in B that have no matching rows in A, Oracle returns null for any select list expressions containing columns of A.
Ex. SELECT empno, ename, job, dname, loc FROM emp e RIGHT OUTER JOIN dept d
ON(e.deptno=d.deptno);                                   OR
SELECT empno, ename, job, dname, loc FROM emp e, dept d WHERE e.deptno(+)=d.deptno;

To write a query that performs an outer join and returns all rows from A and B, extended with nulls if they do not satisfy the join condition (a full outer join), use the FULL [OUTER] JOIN syntax in the FROM clause.
Ex. SELECT empno, ename, job, dname, loc FROM emp e FULL OUTER JOIN dept d
ON(e.deptno=d.deptno);
Download or view topics : Initialization Parameters & Control files


Friday 19 April 2013

You can download a word file for redo log and change vector but it is just short description



Exception Handling
What is an exception?
In PL/SQL, errors and warnings are called as exceptions. Whenever a predefined error occurs in a program, Pl/SQL rises an exception.
There are two types of exception handlers:
1.       Predefined internal exceptions
2.       Userdefined exceptions.

PL/SQL has a collection of predefined exceptions. Each has a name. These exceptions are automatically raised by PL/SQL whenever the corresponding error occurs.
When PL/SQL rises a predefined exception, program is aborted by displaying error message. But if program is to handle exception raised by PL/SQL then we have to use Exception Handler part of the block.


When Exception Handler is given, control is transferred to exception handler whenever there is an exception. After the exception handler is executed, control is transferred to next statement in the enclosing block.

Example of Exception handling:
DECLARE
                X_studid student.studid%type;
BEGIN
                SELECT studid, name FROM students
                WHERE name=’BHARAT PARMAR’;

EXCEPTION
                WHEN NO_DATA_FOUND Then
                INSERT INTO errortable VALUES(‘BHARAT PARMAR Not Found’);
END;

In above example, if no row found with the name ‘BHARAT PARMAR’ then PL/SQL raises exception NO_DATA_FOUND. Then this exception is handled by exception handler and one row is inserted into ERRORTABLE table.

PREDFINED EXCEPTIONS
PL/SQL has defined certain common errors and given names to these errors, which are called as predefined exceptions.

The following is the list of predefined exceptions and the corresponding Oracle Errors:
EXCEPTION NAME                                               ORACLE ERROR
CURSOR_ALREADY_OPEN                                      ORA-06511
DUP_VAL_ON_INDEX                                               ORA-00001
INVALID_CURSOR                                                     ORA-01001
LOGIN_DENIED                                                          ORA-01722
NO_DATA_FOUND                                                     ORA-01017
NOT_LOGGED_ON                                                    ORA-01403
PROGRAM_ERROR                                                    ORA-01012
ROW_TYPE_MISMATCH                                           ORA-06501
STORAGE_ERROR                                                     ORA-06504
TIMEOUT_ON_RESOURCE                                      ORA-06500
TOO_MANY_ROWS                                                  ORA-01422
VALUE_ERROR                                                           ORA-06502
ZERO_DIVIDE                                                             ORA-01476

USER DEFINED EXCEPTION:
PL/SQL allows you to create exceptions of your own. Unlike predefined exceptions, user defined exceptions are to be raised explicitly using RAISE command.
Syntax:
RAISE exception;

Once a user defined exception is raised using RAISE command, it is to be handled just like a predefined exception. The following are the steps of userdefined exceptions:
·         Declare an excpetion in DECLARE section using keyword EXCEPTION.
·         Use RAISE command to raise the exception in the executable part.
·         Handle userdefined exception in exception handler.
Important questions :


1. Explain Oracle instance architecture.
2. What is table space? Explain its types.
3. What is backup? List out types of backup. Explain any two.
4. Explain SQL Loader.
5. Explain Control files, Redo log file.
6. What is Net 8? Explain in details.