The views expressed on this blog are my own and do not necessarily reflect the views of any Organisations owning these products.I keep on doing R & D with different products in and around Middle ware stack and these posts are result of that.Most of the post are result of my own experiments or ideas taken from other blogs .If in any case You feel content is not right you can comment to remove that post. This blog uses the default features,cookies of blogspot.com
Monday, June 02, 2014
PL/SQL Exercises-1
I am a Middleware resource but i was asked to learn EBS technology as it is the base for any business.
I checked with many people few said start with this that etc. But again it was coming down to a single point that i should know pl/sql in order to get technical details of EBS. Luckily one of my friend taught me and gave me a lot of exercises to complete which gave me a good idea of how to do codin in PL/SQL. I am just sharing the exercise as a ready code. This i am sharing so that i can keep a record of the exercises what i have completed and also if some one wanted to use any ready to use code they can simply copy and paste it.
Display even number using loop
SET SERVEROUTPUT ON
DECLARE y NUMBER(3):=0;
BEGIN
LOOP
DBMS_OUTPUT.PUT_LINE(y);
y := y+2;
EXIT WHEN y >= 25;
END LOOP;
END;
/
Display Odd number using loop
SET SERVEROUTPUT ON
DECLARE y NUMBER(3):=1;
BEGIN
LOOP
DBMS_OUTPUT.PUT_LINE(y);
y := y+2;
EXIT WHEN y >= 25;
END LOOP;
END;
/
Display Even number using For
SET SERVEROUTPUT ON
DECLARE x NUMBER(3):=0;
BEGIN
FOR Y IN 1..25
LOOP
DBMS_OUTPUT.PUT_LINE(x);
x := x+2;
END LOOP;
END;
/
Display Odd number using For
SET SERVEROUTPUT ON
DECLARE x NUMBER(3):=1;
BEGIN
FOR Y IN 1..25
LOOP
DBMS_OUTPUT.PUT_LINE(x);
x := x+2;
END LOOP;
END;
/
Display Even number using While
SET SERVEROUTPUT ON
DECLARE
x NUMBER(3):=0;
y INT :=1;
BEGIN
WHILE y < 25
LOOP
DBMS_OUTPUT.PUT_LINE(x);
x := x+2;
y :=y+1;
END LOOP;
END;
/
Display Odd number using While
SET SERVEROUTPUT ON
DECLARE
x NUMBER(3):=1;
y INT :=1;
BEGIN
WHILE y < 25
LOOP
DBMS_OUTPUT.PUT_LINE(x);
x := x+2;
y :=y+1;
END LOOP;
END;
/
Display Even number using MOD Fucntion
SET SERVEROUTPUT ON
DECLARE
y INT :=1;
BEGIN
WHILE y < 25
LOOP
IF (MOD(y,2)=0) THEN
DBMS_OUTPUT.PUT_LINE('Even Number : '||y);
--ELSE
--DBMS_OUTPUT.PUT_LINE('Odd Number');
END IF;
y :=y+1;
END LOOP;
END;
/
Display Odd Number using MOD Function.
SET SERVEROUTPUT ON
DECLARE
y INT :=1;
BEGIN
WHILE y < 25
LOOP
IF (MOD(y,2)!=0) THEN
DBMS_OUTPUT.PUT_LINE('Even Number : '||y);
--ELSE
--DBMS_OUTPUT.PUT_LINE('Odd Number');
END IF;
y :=y+1;
END LOOP;
END;
/
No comments:
Post a Comment