Nested "IF" Statements:
- The "IF" statements can be nested into one another as per requirements.
- Nested "IF" is a situation in which an "IF" follows another "IF" immediately for every "TRUE" state of an "IF" condition.
- Each "IF" is considered as an individual block of "IF" and needs proper nesting.
- Each "IF" block that is opened needs a proper close with "END IF". Else PL/SQL raises exceptions.
- Nested "IF" situations have to be planned when we have a series of conditions fall sequentially.
Syntax:
IF condition THEN
IF condition THEN
IF condition THEN
Statement1;
ELSE
Statement2;
END IF;
ELSE
Statement3;
END IF;
ELSE
Statement4;
END IF;
SQL>DECLARE
v_year NUMBER:=&year;
BEGIN
IF mod(v_year,4)=0 THEN
IF mod(v_year,100)<>0 THEN
DBMS_OUTPUT.PUT_LINE(v_year||'is a leap year');
ELSE
IF mod(v_year,400)=0 THEM
DBMS_OUTPUT.PUT_LINE(v_year||'is a leap year');
ELSE
DBMS_OUTPUT.PUT_LINE(v_year||'is a not a leap year');
END IF;
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE(v_year||'is a not leap year');
END IF;
END;
IF condition THEN
IF condition THEN
IF condition THEN
Statement1;
ELSE
Statement2;
END IF;
ELSE
Statement3;
END IF;
ELSE
Statement4;
END IF;
SQL>DECLARE
v_year NUMBER:=&year;
BEGIN
IF mod(v_year,4)=0 THEN
IF mod(v_year,100)<>0 THEN
DBMS_OUTPUT.PUT_LINE(v_year||'is a leap year');
ELSE
IF mod(v_year,400)=0 THEM
DBMS_OUTPUT.PUT_LINE(v_year||'is a leap year');
ELSE
DBMS_OUTPUT.PUT_LINE(v_year||'is a not a leap year');
END IF;
END IF;
ELSE
DBMS_OUTPUT.PUT_LINE(v_year||'is a not leap year');
END IF;
END;
IF..THEN…ELSE…END IF Statement:
Syntax:
IF condition THEN
Sequences of statements;
ELSE
Sequences of statements;
END IF;
Example-1:
SQL>DECLARE
Firstnum NUMBER:=&Fnum;
Secondnum NUMBER:=&Snum;
BEGIN
IF Firstnum<Secondnum THEN
DBMS_OUTPUT.PUT_LINE('Smallest of two number is'||Firstnum);
ELSE
DBMS_OUTPUT.PUT_LINE('Smallest of two number is'||Secondnum);
END IF;
END;
Example-2:
SQL>DECLARE
Num NUMBER:=&Enternumber;
BEGIN
IF MOD(Num,2)=0 THEN
DBMS_OUTPUT.PUT_LINE(Num||' is an Even Number.');
ELSE
DBMS_OUTPUT.PUT_LINE(Num||'is an Odd Number.');
END IF;
END;
Example-3:
SQL>DECLARE
Number1 NUMBER:=& Number1;
Number2 NUMBER:=& Number2;
BEGIN
IF Number1>Number2 THEN
DBMS_OUTPUT.PUT_LINE('The Greatest Number is:'||Number1);
ELSE
IF Number2>Number1 THEN
DBMS_OUTPUT.PUT_LINE('The Greatest Number is:'||Number2);
ELSE
DBMS_OUTPUT.PUT_LINE('The Number are equal'||Number1||'and'||Number2);
END IF;
END IF;
END;
- IF…THEN…ELSE statement enable us to specify two different groups of statements for execution.
- One group is evaluated when the condition evaluates to “FALSE”.
Syntax:
IF condition THEN
Sequences of statements;
ELSE
Sequences of statements;
END IF;
Example-1:
SQL>DECLARE
Firstnum NUMBER:=&Fnum;
Secondnum NUMBER:=&Snum;
BEGIN
IF Firstnum<Secondnum THEN
DBMS_OUTPUT.PUT_LINE('Smallest of two number is'||Firstnum);
ELSE
DBMS_OUTPUT.PUT_LINE('Smallest of two number is'||Secondnum);
END IF;
END;
Example-2:
SQL>DECLARE
Num NUMBER:=&Enternumber;
BEGIN
IF MOD(Num,2)=0 THEN
DBMS_OUTPUT.PUT_LINE(Num||' is an Even Number.');
ELSE
DBMS_OUTPUT.PUT_LINE(Num||'is an Odd Number.');
END IF;
END;
Example-3:
SQL>DECLARE
Number1 NUMBER:=& Number1;
Number2 NUMBER:=& Number2;
BEGIN
IF Number1>Number2 THEN
DBMS_OUTPUT.PUT_LINE('The Greatest Number is:'||Number1);
ELSE
IF Number2>Number1 THEN
DBMS_OUTPUT.PUT_LINE('The Greatest Number is:'||Number2);
ELSE
DBMS_OUTPUT.PUT_LINE('The Number are equal'||Number1||'and'||Number2);
END IF;
END IF;
END;
IF-THEN-END IF
Syntax:
IF condition THEN
Sequences of statements;
END IF;
Points to Ponder:
- IF…THEN is a reserved word and marks the beginning of the “IF” statement.
- The “END IF” is a reserved phrase that indicates the end of the “IF…THEN” construct.
- When “IF…THEN” is executed, A condition is evaluated to either “TRUE” or “FALSE”.
- Conditions are compared by using either the comparison operators or SQL*plus operators.
- One “IF” keyword can manager any number of conditions at a point of time using the LOGICAL CONNECTIVITIES like “AND”, “OR”.
- Even though the multiple conditions need not be constrained by using brackets, It is better to control their precedence using the proper implementations of brackets to avoid ambiguity.
- Every “IF” that is implemented needs compulsorily a “TRUE” state evaluation for its successful execution, But an evaluation state is not compulsory when the condition is “FALSE”.
- The sequence of statements is executed only if the condition evaluates to true.
- If it is false or null, then the control passes to the statement after ‘END IF”.
SQL>BEGIN
IF ascii('A')=65 THEN
DBMS_OUTPUT.PUT_LINE('This is true');
END IF;
END;
DECLARE
Firstnum NUMBER:=&Fnum;
Secondnum NUMBER:=&Snum;
Temp NUMBER:
BEGIN
DBMS_OUTPUT.PUT_LINE('Original Firstnum='||Firstnum);
DBMS_OUTPUT.PUT_LINE('Original Secondnum='||Secondnum);
IF Firstnum>Secondnum THEN
TEMP:=Firstnum;
Firstnum:=Secondnum;
Secondnum:=Temp;
END IF;
DBMS_OUTPUT.PUT_LINE('Swapped Firstnum='||Firstnum);
DBMS_OUTPUT.PUT_LINE('Swapped Firstnum='||Secondnum);
END;
/
IF ascii('A')=65 THEN
DBMS_OUTPUT.PUT_LINE('This is true');
END IF;
END;
DECLARE
Firstnum NUMBER:=&Fnum;
Secondnum NUMBER:=&Snum;
Temp NUMBER:
BEGIN
DBMS_OUTPUT.PUT_LINE('Original Firstnum='||Firstnum);
DBMS_OUTPUT.PUT_LINE('Original Secondnum='||Secondnum);
IF Firstnum>Secondnum THEN
TEMP:=Firstnum;
Firstnum:=Secondnum;
Secondnum:=Temp;
END IF;
DBMS_OUTPUT.PUT_LINE('Swapped Firstnum='||Firstnum);
DBMS_OUTPUT.PUT_LINE('Swapped Firstnum='||Secondnum);
END;
/
Writing Control Structures:
- PL/SQL can also process data using flow of control statements.
- PL/SQL helps us manipulates and process oracle data using control statements.
- The flow of control statements can be classified under the following categories:
i). Conditional control.
ii). Iterative control.
iii). Sequential control.
ii). Iterative control.
iii). Sequential control.
- IF-THEN-ELSE
- END IF
- ELSIF
- CASE
- END CASE
- LOOP
- FOR-LOOP
- WHILE-LOOP
- END LOOP
- EXIT-WHEN and
- GOTO
Location-Based Spatial Query
Processing in Wireless Broadcast Environments.
Abstract:
Location-based
spatial queries (LBSQ s) refer to spatial queries whose answers rely on the
location of the inquirer. Efficient processing of LBSQ s is of critical
importance with the ever-increasing deployment and use of mobile technologies.
We show that LBSQ s has certain unique characteristics that the traditional
spatial query processing in centralized databases does not address. For
example, a significant challenge is presented by wireless broadcasting
environments, which have excellent scalability but often exhibit high-latency
database access. In this paper, we present a novel query processing technique
that, though maintaining high scalability and accuracy, manages to reduce the
latency considerably in answering LBSQ s. Our approach is based on peer-to-peer
sharing, which enables us to process queries without delay at a mobile host by
using query results cached in its neighboring mobile peers. We demonstrate the
feasibility of our approach through a probabilistic analysis, and we illustrate
the appeal of our technique through extensive simulation results.
Existing System:
Existing
techniques cannot be used effectively in a wireless broadcast environment,
where only sequential data access is supported. It may not scale to very large
user populations. In an existing system to communicate with the server, a
client must most likely use a fee-based cellular-type network to achieve a
reasonable operating range. Third, users must reveal their current location and
send it to the server, which may be undesirable for privacy reasons.
Proposed System:
This
System is a novel approach for reducing the spatial query access latency by
leveraging results from nearby peers in wireless broadcast environments. Our
scheme allows a mobile client to locally verify whether candidate objects
received from peers are indeed part of its own spatial query result set. The
method exhibits great scalability: the higher the mobile peer density, the more
the queries answered by peers. The query access latency can be decreased with
the increase in clients.
System
Requirement Specification:
Software Interface:
JDK
1.5.
Java
Swing.
SQL
Server.
Hardware Interface:
PROCESSOR :
PENTIUM IV 2.6 GHz.
RAM : 512 MB DD RAM.
MONITOR : 15”
COLOR.
HARD DISK : 40 GB.
KEYBOARD : STANDARD 102 KEYS.
MOUSE : 3 BUTTON.
A Distributed Protocol
to Serve Dynamic Groups for Peer-to-Peer Streaming
Abstract:
Peer-to-peer
(P2P) streaming has been widely deployed over the Internet. A streaming system
usually has multiple channels, and peers may form multiple groups for content distribution.
In this paper, we propose a distributed overlay framework (called SMesh) for
dynamic groups where users may frequently hop from one group to another while
the total pool of users remain stable. SMesh first builds a relatively stable
mesh consisting of all hosts for control messaging. The mesh supports dynamic
host joining and leaving, and will guide the construction of delivery trees.
Using the Delaunay Triangulation (DT) protocol as an example, we show how to
construct an efficient mesh with low maintenance cost. We further study various
tree construction mechanisms based on the mesh, including embedded, bypass, and
intermediate trees. Through simulations on Internet-like topologies, we show
that SMesh achieves low delay and low link stress.
Algorithm Used:
Aggregation
and delegation algorithm, Delaunay Triangulation
(DT) Protocol.
Existing System:
P2P
overlay network, hosts are responsible for packets replication and forwarding.
A P2P network only uses unicast and does not need multicast capable routers. It
is, hence, more deployable and flexible. Currently, there are two types of
overlays for P2P streaming: tree structure and gossip mesh. The first one
builds one or multiple overlay tree(s) to distribute data among hosts. Examples
include application-layer multicast protocols.
The
existing networking infrastructure are multicast capable. Emerging commercial
video transport and distribution networks heavily make use of IP multicasting.
However, there are many operational issues that limit the use of IP
multicasting into individual autonomous networks. Furthermore, only trusted
hosts are allowed to be multicast sources. Thus, while it is highly efficient,
IP multicasting is still not an option for P2P streaming at the user level.
Proposed System:
In
the Proposed applications, as peers may dynamically hop
from one group to another, it becomes an important issue to efficiently deliver
specific contents to peers. One obvious approach is to broadcast all contents
to all hosts and let them select the contents. Clearly, this is not efficient
in terms of bandwidth and end-to-end delay, especially for unpopular channels.
Maintaining a separate and distinct delivery overlay for each channel appears
to be another solution. However, this approach introduces high control overhead
to maintain multiple dynamic overlays. When users frequently hop from one
channel to another, overlay reformation becomes costly and may lead to high
packet loss
In
this paper, we consider building a data delivery tree for each group. To reduce
tree construction and maintenance costs, we build a single shared overlay mesh.
The mesh is formed by all peers in the system and is, hence, independent of
joining and leaving events in any group. This relatively stable mesh is used
for control messaging and guiding the construction of overlay trees. With the
help of the mesh, trees can be efficiently constructed with no need of loop
detection and elimination. Since an overlay tree serves only a subset of peers
in the network, we term this framework Subset-Mesh, or SMesh.
Modules:
1. Peer to Peer Network Module.
2. Distributed partition detection Module.
3 .Dynamic Joining Host Module.
4 . Path Aggregation for QoS Provisioning Module.
System Specifications:
Hardware
Requirements:
SYSTEM : Pentium IV 2.4 GHz
HARD DISK : 40 GB
FLOPPY DRIVE :
1.44 MB
MONITOR : 15 VGA colour
MOUSE : Logitech.
RAM : 256 MB
KEYBOARD :
110 keys enhanced.
Software
Requirements:
Operating system : Windows XP Professional
Front End : Java Technology
Tool : Eclipse 3.3
Subscribe to:
Posts (Atom)
Recent Posts
-
03 Java Operators. Program for adding two numbers: //AddingTwoInts.java class AddingTwoInts { public static void main(Stri...
-
SUN Java Wireless Toolkit-2.5.2_01 for Windows: The Sun Java Wireless Toolkit is a state-of-the-art toolbox for developing wireless ap...
-
Host-to-Host Congestion Control for TCP: The Transmission Control Protocol (TCP) carries most Internet traffic, so performance of the In...
0 comments: