Monday, February 11, 2019

Assignment in SQL for Using trigger


Assignment:-               
Assign. Name:-Using Trigger
CLASS:-T.Y.B.Sc(Computer)     



     *************************************************************

Triggers:-

 SQL> select * from purchase

 PO_NO   PO_DATE     ITEM_NO    QTY
 --------  ---------            ----------    ---------
 11          12-MAY-03      101        100
 12          17-JUN-03       102        75
 13          21-APR-03       103        150
 14          14-JAN-04       104        100

 SQL> select * from stock;

 ITEM_NO       QTY
-----------  -----------
  101            100
  102             75
  103            150
  104            100

      <1>                       

     create or replace trigger ptr1 before insert on purchase for each row
     declare
     v1 integer;
     begin
    select count(*) into v1 from stock
    where Itrmno=:new.Item_no;
    if v1=0 then
    insert into stock values(:new.Itemno,:new.qty)
    else
    update stock set qty=qty+:new.qty
    where Itemno=:new.Itemno;
    end if;
    end;
    /
SQL> select * from purchase;

Assignment in SQL for use of set operator


Assignment:-               

Assign. Name:- In SQL Use of SET Operator.

CLASS:-T.Y.B.Sc(Computer)          

*************************************************************

Use of SET Operator:
- UNION
- INTERSECT
- IN
- NOT IN

SQL>select * from borrower;

 CUST_NAME                 LOAN_NO
---------------------    -------------
Samir                            1
Mahesh                         2
Smita                            3
Vrushali                         4
Devendra                       5
Vaibhav                         6

UNION:-
SQL> (select cust_name from borrower) UNION
     (select cust_name from depositer);
 CUST_NAME
-----------------------
 Devendra
 Mahesh
 Samir
 Smita
 Vaibhav
 Vrushali
  6 rows selected.
SQL> (Select cust_name from borrower) UNION ALL
     (Select cust_name from depositer);

    CUST_NAME
---------------------------------
    Samir
    Mahesh
    Smita
    Vrushali
    Devendra
    Vaibhav
    Samir
    Mahesh
    Samita
    Vrushali
    Devendra   

    

11 row selected.

INTERSECT:-

SQL> (Select cust_name from borrower) INTERSECT
     (Select cust_name from depositer);

    CUST_NAME
  ----------------------------
    Devendra
    Mahesh
    Samir
    Smita
    Vrushali

 IN:-

SQL> Select DISTINCT cust_name from borrower WHERE
     cust_name IN (Select cust_name from depositer);

    CUST_NAME
       ------------------------
    Devendra
    Mahesh
    Samir
    Smita
    Vrushali

 NOT IN:-

SQL> Select DISTINCT cust_name from borrower WHERE
     cust_name NOT IN (Select cust_name from depositer);

    CUST_NAME
    ----------------------
    Vaibhav
   

Assignment for SQL Queries Operations TYBSc(computer science)



Assignment :-               
Assign. Name:-SQL Queries Operations
CLASS:-T.Y.B.Sc. (Computer)      

*************************************************************
            SQL Queries on Single Table

SQL Simple Queries:-
            -Select Clause
            -From  Clause
            -Where  Clause

LOAN_NO            BNAME            AMMOUNT
--------------        ------------        ----------------
1            M G ROAD            10000
2            J M ROAD            15000
3            F C ROAD            12000
4            G P ROAD            25000
5            M G ROAD            18000
6            J M ROAD            5000
7            G P ROAD            20000

Example1:-  Find the distinct name of branches in the loan.

SQL>select distinct Bname from loan;
       BNAME
-----------------------
    F C ROAD
     G P ROAD
    J M ROAD
     M G ROAD

Example2:-Find the loan number of those 10000<=loan amount<=25000.

SQL>select loan_no from loan where amount>=10000 AND amount<=25000;

     LOAN_NO
--------------------------
     1
     2
     3
     4
     5
     7

 Example3:- Find the loan number,branch name amount of those loans amount between 10000 and 20000.

SQL> select * from loan where amount BETWEEN 10000 AND 20000;
    LOAN_NO        BNAME              AMOUNT       
-----------------         --------------        -----------------
  1                    M G ROAD            10000
  2                   J M ROAD            15000
  3                   F C ROAD            12000
  5                 M G ROAD            18000
  7                 G P ROAD            20000
 
Example4:- Find all the attribute in loan where interest on the amount is calculated as 3% of the amount.

SQL> select loan_no,Bname,Amount,Amount*0.03 from loan;

LOAN_NO          BNAME              AMOUNT             AMOUNT*0.03
-----------------      --------------        -----------------       ----------------------
  1                 M G ROAD            10000                    300
  2                 J M ROAD            15000                    450
  3                 F C ROAD            12000                    360
  4                G P ROAD            25000                    750
  5                M G ROAD            18000                    540
  6               J M ROAD            5000                    150
  7                G P ROAD            20000                    600

Example5:- Find all the attribute in loam where branch name equal to J M Road.

SQL>select loan_no,Bname,amount from loan where Banme='J M Road';

LOAN_NO       BNAME                    AMMOUNT
---------------     --------------        ------------------
 2                 J M ROAD                15000
 6                 J M ROAD                5000

Example6:- Find all the attribute in loan where adds (using + operator ) 500 in amount.

SQL> select loan_no,Bname,amount,amount+500 from loan;

LOAN_NO         BNAME              AMOUNT             AMOUNT+500
-----------------        --------------        -----------------       ----------------------
  1                    M G ROAD            10000                10500
  2                     J M ROAD            15000                15500
  3                     F C ROAD            12000                12500
  4                    G P ROAD            25000                25500
  5                     M G ROAD            18000                18500
  6                    J M ROAD            5000                5500
  7                    G P ROAD            20000                20500

Sunday, February 10, 2019

Match Making for you

Match making


Click above link to fill the form

Java program for String operations in swing





JAVA PROGRAM FOR String Operations in swing:



import java.awt.*;
import  java.lang.*;
import java.awt.event.*;
import javax.swing.*;

/*<applet code="StrOp" width=400 height=400></applet>*/

public class StrOp extends JApplet implements ActionListener
{
        JTextField text5;
       JTextField text4;
        JTextField text3;
       JTextField text2;
        JTextField text1;
        public void init()
        {
                Container contentPane=getContentPane();
                contentPane.setLayout(new GridLayout(5,2,40,40));
                JLabel enter=new JLabel("Enter String:");
                contentPane.add(enter);
                text1=new JTextField();
                contentPane.add(text1);
                JButton lower=new JButton("LOWER");
                lower.addActionListener(this);
                contentPane.add(lower);
                text2=new JTextField();
                contentPane.add(text2);
                JButton upper=new JButton("UPPER");
                upper.addActionListener(this);
                contentPane.add(upper);
                text3=new JTextField();
                contentPane.add(text3);
                JButton italic=new JButton("ITALIC");
         
                 italic.addActionListener(this);
                contentPane.add(italic);
                text4=new JTextField();
                text4.setFont(new Font("TimesNewRoman",Font.ITALIC,12));
                contentPane.add(text4);
                JButton bold=new JButton("BOLD");
                bold.addActionListener(this);
                contentPane.add(bold);
                text5=new JTextField();
                text5.setFont(new Font("TimesNewRoman",Font.BOLD,12));
                contentPane.add(text5);
       }
       public void actionPerformed(ActionEvent e)
       {
                String str=text1.getText();
                if(e.getActionCommand()=="LOWER")
                        text2.setText(str.toLowerCase());
                else if(e.getActionCommand()=="UPPER")
                        text3.setText(str.toUpperCase());
                else if(e.getActionCommand()=="ITALIC")
                        text4.setText(str);
                else if(e.getActionCommand()=="BOLD")
                        text5.setText(str);
       }
}












*****************************************



OUTPUT
*****************************************

Enter String     :  vijay

Lower              :  vijay

Upper              :  VIJAY
Italic                :  vijay
Bold                :   vijay

Java Program for Inheritance




JAVA PROGRAM FOR INHERITANCE:




import java.io.*;
 class Base
 {
     int a,b;
     void get( )
     {
         InputStreamReader ip=new InputStreamReader(System.in);
         BufferedReader br=new BufferedReader(ip);
         String ap;
         try
         {
            System.out.println("Enter Value of A:");
            ap=br.readLine( );
            a=Integer.parseInt(ap);

            System.out.println("Enter Value of B:");
            ap=br.readLine( );
            b=Integer.parseInt(ap);
           }
          catch(Exception e)
          {
            System.out.println(e);
           }
        }
    }
 class Derived extends Base
 {
    void disMin( )
    {
       if(a<b)
        System.out.println("Minimum Value is A:"+a);
       else
        System.out.println("Minimum Value is B:"+b);
       }
    void disMax( )
    {
       if(a>b)
         System.out.println("Maximum Value is A:"+a);
       else
         System.out.println("Maximum Value is B:"+b);
       }
   }
 class Inheritance
 {
   public static void main(String args[])
   {
      Derived dd=new Derived( );
      dd.get( );
      dd.disMin( );
      dd.disMax( );
    }
 }


*****************************************


OUTPUT:

*****************************************      
C:\vijay\advjava\jdk1.4\bin>java Base

Enter Value of A:
232
Enter Value of B:
236

Minimum Value is A:232
Maximum Value is B:236

C:\vijay\advjava\jdk1.4\bin>








Java program for square root




Java program for square root:



import java.awt.*;
import java.awt.event.*;
import java.io.*;

class SqRoot extends Frame implements ActionListener
 {
   TextField t1,t2;
   Label l1,l2;
   Button b1,b2;

   SqRoot()
   {
    setVisible(true);
    setTitle("Special Purpose Claculator");
    setSize(400,400);
  
      l1=new Label("Input no.");
      l2=new Label("Output");
    
      t1=new TextField(10);
      t2=new TextField(10);

      b1=new Button("Calculate");
      b2=new Button("Clear");
      b1.addActionListener(this);
      b2.addActionListener(this);

     Panel p1=new Panel( );
     p1.setLayout(new GridLayout(2,2));

     p1.add(l1);
     p1.add(t1);
     p1.add(l2);
     p1.add(t2);





     Panel p2=new Panel( );
     p2.setLayout(new FlowLayout( ));

     p2.add(b1);
     p2.add(b2);

     Panel p3=new Panel();
     p3.setLayout(new GridLayout(2,1));
     p3.add(p1);
     p3.add(p2);
    add(p3);

   }
  public void actionPerformed(ActionEvent ae)
  {
    try
    {
      if(ae.getSource( )==b1)
      {
        int n=Integer.parseInt(t1.getText( ));
        double y;
        y= Math.sqrt(n);
        t2.setText(""+y);
      }
   else
      {
        t1.setText("");
        t2.setText("");
     }
   }
     catch(Exception e)
     {
       System.out.println("Error..."+e);
        dispose( );
      }

  }
   public static void main(String args[])
   {
     SqRoot s=new SqRoot( );
     s.validate( );
   }
}

AI internal programming

  AI's internal programming involves complex algorithms and data structures that enable machines to learn, reason, and interact. Here...