Thursday, April 8, 2010

lab manual of software practices

PRACTICALS
1.(Using if….end if)
Create a table stud_muster (st_id, st_name, report_date,contact,sem,status) and write a PL/SQL
block to update the status of stud_muster by checking the difference of current date and
report_date,if it happens to be greater than 5 yrs set the status to “disqualified” else “pursuing”
using conditional operator if…end if.


 2.(Using Loop)
Write a PL/SQL code block to print the records of the students whose id ranges from 015 to
025 using for, while, simple loop. (Use stud_muster table as mentioned above).




3.(Using Implicit Cursor)
The bank manager of a branch say “ABC” has decided to activate all those accounts which
were previously marked inactivate for not performing transactions in last 365 days. Write a Pl/
SQL block to update the status of accounts. Display an appropriate message for the rows
affected.




4.( Using Explicit Cursor)
Write a PL/SQL block that will display the customer name, the fixed deposit number and the
fixed deposit amount of the first 10 customers holding highest amount in fixed deposits.
(Hint: Declare explicit cursor in the query).




5.(Using Procedure)
Write a procedure to check the status of various orders taken by an enterprise XYZ and display
the appropriate message using IN parameter.
Using OUT parameter –write a procedure to check the quantities ordered for various orders




6.(Using Functions)
Write a function and block code to execute to know the quantity on hand and reorder level
.Before ordering of new goods it is needed to check if they exceeded the maximum limit of
particular item.
If yes then they should be stored in some other function if no then they should be placed in
orders.




7. Design a form which insert & Delete a record of Student Details in Data Grid.




8. Develop a small Database entry form using ADO(Bounded) for Student Profile.
and Perform the Following operation.
• Insert a Record
• Delete a Record
• Update a Record
• Search a Record




9. Develop a small Database entry form using ADO(Unbounded) for employee profile
and Perform the Following operation.
• Insert a Record
• Delete a Record
• Update a Record
• Search a Record




10. Develop a small Database Management System for Student profile using following
Data Awareness Control with ADO.
• Data Grid
• Data Combo
• Data List




11. Develop a small Database entry form using ADO(Unbounded) for employee Profile. Fetch
the Record through Function or Store Procedure. Perform the Following operation.
• Insert a Record
• Delete a Record
• Update a Record
• Search a Record




12. Design a different Data Report for Employee/Student Profile.
(Fetch the Record from Database through Stored Procedure or Function)
• Singular Report
• All Employee/Student Report
• Joining Date Wise Report
• Age Wise Report
• Designation/Semester Wise Report

lab manual of software engineering

LABORATORY EXPERIENCES
1. To sturdy software characteristics.
2. To study different types of software applications.
3. To understand and development various process models.
4. To study Logical Data Flow Diagrams.
5. To study Logical Data Flow Diagrams.
6. To study & Explain software measurement metrics
7. To study Project Estimation.
8. To study software risks.
9. To Study Software Quality Assurance (S.Q.A.) concept.
10. To study different software testing methods
11. Overview of CASE Tool.

Wednesday, April 7, 2010

tutorial by jignesh sir for sp

Introduction

What is PL/SQL?
PL/SQL stands for Procedural Language extension of SQL.

PL/SQL is a combination of SQL along with the procedural features of programming languages. It was developed by Oracle Corporation in the early 90’s to enhance the capabilities of SQL.
The PL/SQL Engine:

Oracle uses a PL/SQL engine to processes the PL/SQL statements. A PL/SQL code can be stored in the client system (client-side) or in the database (server-side).

A Simple PL/SQL Block:

Each PL/SQL program consists of SQL and PL/SQL statements which from a PL/SQL block.

A PL/SQL Block consists of three sections:
  • The Declaration section (optional).
  • The Execution section (mandatory).
  • The Exception (or Error) Handling section (optional).
Declaration Section:
The Declaration section of a PL/SQL Block starts with the reserved keyword DECLARE. This section is optional and is used to declare any placeholders like variables, constants, records and cursors, which are used to manipulate data in the execution section. Placeholders may be any of Variables, Constants and Records, which stores data temporarily. Cursors are also declared in this section.
Execution Section:
The Execution section of a PL/SQL Block starts with the reserved keyword BEGIN and ends with END. This is a mandatory section and is the section where the program logic is written to perform any task. The programmatic constructs like loops, conditional statement and SQL statements form the part of execution section.
Exception Section:
The Exception section of a PL/SQL Block starts with the reserved keyword EXCEPTION. This section is optional. Any errors in the program can be handled in this section, so that the PL/SQL Blocks terminates gracefully. If the PL/SQL Block contains exceptions that cannot be handled, the Block terminates abruptly with errors.

Every statement in the above three sections must end with a semicolon 
; . PL/SQL blocks can be nested within other PL/SQL blocks. Comments can be used to document code.

This is how a sample PL/SQL Block looks.

DECLARE
     Variable declaration
BEGIN
     Program Execution
EXCEPTION
     Exception handling
END;

Advantages of PL/SQL

These are the advantages of PL/SQL.
  • Block Structures: PL SQL consists of blocks of code, which can be nested within each other. Each block forms a unit of a task or a logical module. PL/SQL Blocks can be stored in the database and reused.
  • Procedural Language Capability: PL SQL consists of procedural language constructs such as conditional statements (if else statements) and loops like (FOR loops).
  • Better Performance: PL SQL engine processes multiple SQL statements simultaneously as a single block, thereby reducing network traffic.
  • Error Handling: PL/SQL handles errors or exceptions effectively during the execution of a PL/SQL program. Once an exception is caught, specific actions can be taken depending upon the type of the exception or it can be displayed to the user with a message.

PL/SQL Placeholders

Placeholders are temporary storage area. Placeholders can be any of Variables, Constants and Records. Oracle defines placeholders to store data temporarily, which are used to manipulate data during the execution of a PL SQL block.

Depending on the kind of data you want to store, you can define placeholders with a name and a datatype. Few of the datatypes used to define placeholders are as given below.
Number (n,m) , Char (n) , Varchar2 (n) , Date , Long , Long raw, Raw, Blob, Clob, Nclob, Bfile

PL/SQL Variables
These are placeholders that store the values that can change through the PL/SQL Block.

The General Syntax to declare a variable is:
variable_name datatype [NOT NULL := value ];
  • variable_name is the name of the variable.
  • datatype is a valid PL/SQL datatype.
  • NOT NULL is an optional specification on the variable.
  • value or DEFAULT valueis also an optional specification, where you can initialize a variable.
  • Each variable declaration is a separate statement and must be terminated by a semicolon.

For example, if you want to store the current salary of an employee, you can use a variable.
DECLARE
salary  number (6);
* “salary” is a variable of datatype number and of length 6.

When a variable is specified as NOT NULL, you must initialize the variable when it is declared.

For example: The below example declares two variables, one of which is a not null.
DECLARE
salary number(4);
dept varchar2(10) NOT NULL := “HR Dept”;
The value of a variable can change in the execution or exception section of the PL/SQL Block. We can assign values to variables in the two ways given below.
1) We can directly assign values to variables.
    The General Syntax is:
variable_name:=  value;
2) We can assign values to variables directly from the database columns by using a SELECT.. INTO statement. The General Syntax is:
SELECT column_name
INTO variable_name
FROM table_name
[WHERE condition];
Example: The below program will get the salary of an employee with id '1116' and display it on the screen.
DECLARE
var_salary number(6);
var_emp_id number(6) = 1116;
BEGIN
SELECT salary
INTO var_salary
FROM employee
WHERE emp_id = var_emp_id;
dbms_output.put_line(var_salary);
dbms_output.put_line('The employee '
|| var_emp_id || ' has  salary  ' || var_salary);
END;
/
NOTE: The backward slash '/' in the above program indicates to execute the above PL/SQL Block.
Scope of Variables
PL/SQL allows the nesting of Blocks within Blocks i.e, the Execution section of an outer block can contain inner blocks. Therefore, a variable which is accessible to an outer Block is also accessible to all nested inner Blocks. The variables declared in the inner blocks are not accessible to outer blocks. Based on their declaration we can classify variables into two types.
  • Local variables - These are declared in a inner block and cannot be referenced by outside Blocks.
  • Global variables - These are declared in a outer block and can be referenced by its itself and by its inner blocks.
For Example: In the below example we are creating two variables in the outer block and assigning thier product to the third variable created in the inner block. The variable 'var_mult' is declared in the inner block, so cannot be accessed in the outer block i.e. it cannot be accessed after line 11. The variables 'var_num1' and 'var_num2' can be accessed anywhere in the block.
1> DECLARE
2>  var_num1 number;
3>  var_num2 number;
4> BEGIN
5>  var_num1 := 100;
6>  var_num2 := 200;
7>  DECLARE
8>   var_mult number;
9>   BEGIN
10>    var_mult := var_num1 * var_num2;
11>   END;
12> END;
13> /

As the name implies a constant is a value used in a PL/SQL Block that remains unchanged throughout the program. A constant is a user-defined literal value. You can declare a constant and use it instead of actual value.
For example: If you want to write a program which will increase the salary of the employees by 25%, you can declare a constant and use it throughout the program. Next time when you want to increase the salary again you can change the value of the constant which will be easier than changing the actual value throughout the program.
The General Syntax to declare a constant is:
constant_name CONSTANT datatype := VALUE; 
  • constant_name is the name of the constant i.e. similar to a variable name.
  • The word CONSTANT is a reserved word and ensures that the value does not change.
  • VALUE - It is a value which must be assigned to a constant when it is declared. You cannot assign a value later.
For example, to declare salary_increase, you can write code as follows:
DECLARE
salary_increase CONSTANT number (3) := 10;
You must assign a value to a constant at the time you declare it. If you do not assign a value to a constant while declaring it and try to assign a value in the execution section, you will get a error. If you execute the below Pl/SQL block you will get error.
DECLARE
 salary_increase CONSTANT number(3); 
BEGIN
 salary_increase := 100;
 dbms_output.put_line (salary_increase); 
END;