Saturday, 11 August 2018

Oracle / PLSQL: IF-THEN-ELSE Statement

SET SERVEROUTPUT ON;

DECLARE
   a number(3) := 100;
   b number(3) := 200;
BEGIN
   IF( a = 100 ) THEN
      IF( b <> 200 ) THEN
         dbms_output.put_line(b);
      END IF;
   END IF;
   dbms_output.put_line(a);
END;

/

Simple PL/SQL Program

SET SERVEROUTPUT ON;

DECLARE
   c_id varchar2(100):= 'AR';
   r_id  varchar2(100);
   c_name varchar2(100);
  BEGIN
   SELECT region_id, country_name INTO r_id, c_name
   FROM countries
   WHERE country_id = c_id;
  dbms_output.put_line('Region Id is: '|| c_id || ' Country Name is: '|| c_name);

END;

/

Oracle / PLSQL: IF-THEN-ELSE-IF-ELSE Statement

SET SERVEROUTPUT ON;

DECLARE
   a number(3) := 100;
BEGIN
   IF (a = 50 ) THEN
      dbms_output.put_line('Value of a is 80' );
   ELSIF ( a = 75 ) then
      dbms_output.put_line('Value of a is 76' );
   ELSE
       dbms_output.put_line('None of the values is matching');
   END IF;
   dbms_output.put_line('Real value of a is: '|| a );
END;

/

PL/SQL Basic Loop Statement

SET SERVEROUTPUT ON ;

DECLARE
   x number := 4;
BEGIN
   LOOP
      dbms_output.put_line(x);
      x := x + 1;
      exit WHEN x > 5;
   END LOOP;
      dbms_output.put_line(x);
END;

/

Oracle / PLSQL: FOR LOOP IN REVERSE

SET SERVEROUTPUT ON:

Declare
b2 varchar2(100);
Begin
select count(*) into b2 from countries;
for i in reverse 1..b2 loop
dbms_output.put_line('Reverse Value is: '|| i);
end loop;
end;
/

Simple Program of Java

class object
{
public int id=10;
public String name="Balwant";
public static void main(String args[])
{
object ob = new object();
System.out.println("\n" + "" +ob.id);
System.out.print(ob.name);
}
}

Saturday, 7 July 2018

Java Program for Classes and Objects

class object_new
{
int id;
String name;

public void method1(int d,String n)
{
id = d;
name = n;
}
public void display()
{
System.out.println("My id is :"+ id);
System.out.println("My name is :"+ name);
}
}
class object1
{
public static void main(String args[])
{
object_new obj=new object_new();
object_new obj1=new object_new();
obj.method1(99,"Balwant Singh");
obj1.method1(101,"BSB");
obj.display();
obj1.display();
}
}

Basic Java Program

class basic
{
public static void main(String args[])
{
System.out.println("This is first Basic Program for programmers");
}
}

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...