db&wt lab manual

Upload: barbara-lee

Post on 05-Apr-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Db&Wt Lab Manual

    1/38

    Ex. No: 1Date : / / 2007

    Basic SQL Commands

    AIM: To execute basic SQL commands in SQL server environment.

    ALGORITHM:

    Step 1: Start the program

    Step 2: The prompted Login-id and password (Oracle) once given, SQL> prompt appearsand connected to the Oracle DBA. Now ready to access to PL/SQL commandsand statement to DBA.

    Step 3: Execute various SQL commands in the SQL server environment.

    Step 4: Verify the output of each command and statements executed.

    Step 5: Print out with the necessary details.

    1

  • 7/31/2019 Db&Wt Lab Manual

    2/38

    OUTPUT:

    SQL>create table employee(empno number(3) primary key, empname varchar2(15),2 addr varchar(20), dob date, mailid varchar2(25));

    Table created.-----------------------------------------------------------------------------------------------------------SQL> desc employee;Name Null? Type------------------------------------------------------------------------EMPNO NOT NULL NUMBER(4)EMPNAME VARCHAR2(15)ADDR VARCHAR2(20)DOB DATEMAILID VARCHAR2(25)

    -----------------------------------------------------------------------------------------------------------SQL> alter table employee modify empno number(6);

    Table altered.-----------------------------------------------------------------------------------------------------------SQL> insert into employee values(&empno,'&empname','&addr','&dob','&emailid');Enter value for empno: 55Enter value for empname: RadhikaEnter value for addr: R.S.Puram,ChennaiEnter value for dob: 12-NOV-85Enter value for emailid: [email protected]

    old 1: insert into employee values(&empno,'&empname','&addr','&dob','&emailid')new 1: insert into employee values(55,'Radhika','R.S.Puram,Chennai','12-NOV-85','radhi@rediffmail.

    1 row created.

    SQL> insert into employee values(143,'Shiva','Vadapalani,Chennai','26-SEP-80','[email protected]');

    1 row created.-----------------------------------------------------------------------------------------------------------SQL> select * from employee;

    EMPNO EMPNAME ADDR DOB MAILID--------- --------------- -------------------- --------- -------------------------

    55 Radhika R.S.Puram,Chennai 12-NOV-85 [email protected] Balaji Poes Garden,Chennai 15-NOV-85 [email protected] Divya Jainagar,CBE 12-NOV-85 [email protected] Shiva Vadapalani,Chennai 26-SEP-80 [email protected]

    2

  • 7/31/2019 Db&Wt Lab Manual

    3/38

    SQL> select distinct(dob) from employee;

    DOB---------26-SEP-8012-NOV-8515-NOV-85------------------------------------------------------------------------------------------------------------SQL> delete from employee where empno=55;

    1 row deleted.

    SQL> select * from employee;

    EMPNO EMPNAME ADDR DOB MAILID--------- --------------- -------------------- --------- -------------------------

    101 Balaji Poes Garden,Chennai 15-NOV-85 [email protected] Divya Jainagar,CBE 12-NOV-85 [email protected] Shiva Vadapalani,Chennai 26-SEP-80 [email protected]

    SQL>update employee set empno=empno+3 where dob='12-NOV-85'

    1 row updated.----------------------------------------------------------------------------------------------------------

    SQL> select * from employee;

    EMPNO EMPNAME ADDR DOB MAILID--------- --------------- -------------------- --------- -------------------------

    101 Balaji Poes Garden,Chennai 15-NOV-85 [email protected] Divya Jainagar,CBE 12-NOV-85 [email protected] Shiva Vadapalani,Chennai 26-SEP-80 [email protected]

    ----------------------------------------------------------------------------------------------------------SQL> select min(empno) from employee;

    MIN(EMPNO)----------

    51----------------------------------------------------------------------------------------------------------SQL> select max(empno) from employee;MAX(EMPNO)----------

    143----------------------------------------------------------------------------------------------------------

    SQL> select sum(empno) from employee;

    SUM(EMPNO)----------

    295

    3

  • 7/31/2019 Db&Wt Lab Manual

    4/38

    ----------------------------------------------------------------------------------------------------------

    SQL> select avg(empno) from employee;

    AVG(EMPNO)----------98.333333

    ----------------------------------------------------------------------------------------------------------

    SQL> select * from employee where empno>100 or dob='26-sep-80';

    EMPNO EMPNAME ADDR DOB MAILID--------- --------------- -------------------- --------- -------------------------

    101 Balaji Poes Garden,Chennai 15-NOV-85 [email protected] Shiva Vadapalani,Chennai 26-SEP-80 [email protected]

    ----------------------------------------------------------------------------------------------------------

    SQL> create view empview as select empno,addr,mailid from employee

    View created.

    SQL> select * from empview;

    EMPNO ADDR MAILID--------- -------------------- -------------------------

    101 Poes Garden,Chennai [email protected] Jainagar,CBE [email protected]

    143 Vadapalani,Chennai shivbp@hotmail.com----------------------------------------------------------------------------------------------------------SQL>commit;

    Commit complete.----------------------------------------------------------------------------------------------------------SQL>

    4

  • 7/31/2019 Db&Wt Lab Manual

    5/38

    Ex. No: .2Date : / / 2007

    NORMALIZATION

    AIM: To create database (table) and implement the normalization concept to the databasein SQL server environment.

    ALGORITHM:

    Step 1: Start the program

    Step 2: The prompted Login-id and password (Oracle) once given, SQL> prompt appears

    and connected to the Oracle DBA. Now ready to access to PL/SQL commandsand statement to DBA.

    Step 3: Create table insert data into the table.

    Step 4: Create view table for implementing normalization concept.

    Step 5: Show the result of 1NF, 2NF and 3NF of the given database.

    Step 6: Print out with the necessary details.

    5

  • 7/31/2019 Db&Wt Lab Manual

    6/38

    OUTPUT:

    0 NF Normal table without constraints

    CUSTOMER ORDER TABLE

    SQL> desc custord;Name Null? Type----------------------------------------------------- -------- ---------------CUSTNAME VARCHAR2(15)PRODNO NUMBER(4)PRODDESC VARCHAR2(15)QTY NUMBER(4)CUSTADDR VARCHAR2(20)DATEORD DATEORDNO NUMBER(4)

    SQL> select * from custord;

    CUSTNAME PRODNO PRODDESC QTY CUSTADDR DATEORD ORDNO--------------- --------- --------------- --------- -------------------- --------- ---------------------Shobana 5 Chocolate 200 Ambur 29-MAR-83 5Abi 459 Shirts 5 Vellore 16-JUN-00 15Karan 256 Pen 2 Chennai 03-MAY-06 70

    1 NF remove multi valued attributes

    Virtual view files created as customer(custname,custaddr)view files created as customer_order(custname,ordno,prodno,proddesc,qty,dateord)

    SQL> select * from customer;

    CUSTNAME CUSTADDR--------------- --------------------

    Shobana AmburAbi VelloreKaran Chennai

    SQL> select * from customer_order;

    CUSTNAME ORDNO PRODNO PRODDESC QTY DATEORD--------------- --------- --------- --------------- --------- ---------Shobana 5 5 Chocolate 200 29-MAR-83Abi 15 459 Shirts 5 16-JUN-00Karan 70 256 Pen 2 03-MAY-06

    6

  • 7/31/2019 Db&Wt Lab Manual

    7/38

    2 NF remove partial dependencies

    Virtual view files created as customer(custname,custaddr)Virtual view created as order(custname,ordno)Virtual view files created as cust_order(ordno,prodno,proddesc,qty,dateord)

    SQL> select * from customer;

    CUSTNAME CUSTADDR--------------- --------------------Shobana AmburAbi VelloreKaran Chennai

    SQL> select * from c_order;

    CUSTNAME ORDNO--------------- -----------------Shobana 5Abi 15Karan 70

    SQL> select * from cust_order;

    ORDNO PRODNO PRODDESC QTY DATEORD--------------- --------- --------- --------------- --------- --------------------5 5 Chocolate 200 29-MAR-83

    459 5 Shirts 5 16-JUN-0070 256 Pen 2 03-MAY-06

    3 NF remove transitive decencies

    Virtual view files created as customer(custname,custaddr)Virtual view created as order(custname,ordno)Virtual view files created as cust_order(ordno,prodno,qty,dateord)Virtual view file created as product(prodno, proddesc)

    SQL> select * from customer;

    CUSTNAME CUSTADDR--------------- --------------------Shobana AmburAbi VelloreKaran Chennai

    SQL> select * from c_order;

    CUSTNAME ORDNO--------------- -----------------Shobana 5

    7

  • 7/31/2019 Db&Wt Lab Manual

    8/38

    Abi 15Karan 70

    SQL> select * from ord_only;

    ORDNO PRODNO QTY DATEORD--------- --------- --------- ---------------------------

    5 5 200 29-MAR-8315 459 5 16-JUN-0070 256 2 03-MAY-06

    SQL> select * from product;

    PRODNO PRODDESC--------- ---------------

    5 Chocolate

    459 Shirts256 Pen

    SQL> commit;Commit complete.

    RESULT :

    Thus a database (table) was created and the normalization concept to the databasein SQL server environment was implemented.

    8

  • 7/31/2019 Db&Wt Lab Manual

    9/38

    Ex. No : .3Date : / / 2007

    INVENTORY

    AIM: To implement inventory control, create database (table) and develop PL/SQLprocedure to demonstrate inventory record.

    ALGORITHM:

    Step 1: Start the program

    Step 2: The prompted Login-id and password (Oracle) once given, SQL> prompt appears

    and connected to the Oracle DBA. Now ready to access to PL/SQL commandsand statement to DBA.

    Step 3: Create table suitable for inventory.

    Step 4: Develop PL/SQL procedure and compile successfully..

    Step 5: Take input from the user for the given database.

    Step 6: Print out with the necessary details.

    9

  • 7/31/2019 Db&Wt Lab Manual

    10/38

    SOURCE CODE:

    SQL> create table trans(bno number(3), bname varchar2(15),authu varchar2(15), nofcanumber(6),tamount number(6));

    SQL> desc trans;Name Null? Type----------------------------------------- -------- ----------------------------BNO NUMBER(3)BNAME VARCHAR2(15)AUTHU VARCHAR2(15)NOFCA NUMBER(6)TAMOUNT NUMBER(6)

    SQL> create table bookstock as select * from trans;

    Table created.SQL> desc bookstock;Name Null? Type----------------------------------------- -------- ----------------------------BNO NUMBER(3)BNAME VARCHAR2(15)AUTHU VARCHAR2(15)NOFCA NUMBER(6)TAMOUNT NUMBER(6)

    SQL> edWrote file afiedt.buf

    1 declare2 b varchar2(15);3 n number(4);4 l number(4);5 t number(10);6 a number(4);7 bookrec bookstock%rowtype;

    8 cursor cur is select *from bookstock;9 begin10 l:=0;11 open cur;12 loop13 fetch cur into bookrec;14 exit when cur%notfound;15 b:='&bname';16 if(bookrec.bname=b)then17 l:=1;18 n:=&no_of_copy_reqd;19 if(bookrec.nofca>n)then20 t:= bookrec.nofca-n;21 a:=bookrec.tamount*n;

    10

  • 7/31/2019 Db&Wt Lab Manual

    11/38

    22 update bookstock set tamount=t where bname=b;23 insert into trans values(bookrec.bno,b,bookrec.authu,n,a);24 else25 dbms_output.Put_line('Not available');26 end if;27 end if;28 end loop;29 close cur;30 if l=0 then31 dbms_output.Put_line('Not available');32 end if;33* end;

    SQL> /Enter value for bname: seold 15: b:='&bname';new 15: b:='se';Enter value for no_of_copy_reqd: 2

    old 18: n:=&no_of_copy_reqd;new 18: n:=2;

    PL/SQL procedure successfully completed.

    OUTPUT:

    SQL>Enter value for book_name: ansi

    old 15:b=&book_name;new 15:b=ansi;Enter value for no_of_copy_required: 2New 15:n=2;PL/SQL procedure successfully completed.

    SQL> select *from trans;BNO BNAM AUTHU NOFCA TAMOUNT100 ansi name 2 200

    RESULT:

    Thus we implemented inventory control, created database (table) and developed PL/SQLprocedure to demonstrate inventory record.

    11

  • 7/31/2019 Db&Wt Lab Manual

    12/38

  • 7/31/2019 Db&Wt Lab Manual

    13/38

    OUTPUT:

    SQL> create table bank(sbno1 number(3),name1 varchar2(15),addr1 varchar2(25),balance1number(6),interest1 number(3),total1 number(6),depdate1 date,intdate1 date);

    Table created.------------------------------------------------------------------------------------------------------------------------SQL> desc bank;Name Null? Type-----------------------------------------------------------------------------SBNO1 NUMBER(3)NAME1 VARCHAR2(15)ADDR1 VARCHAR2(25)BALANCE1 NUMBER(6)INTEREST1 NUMBER(4)TOTAL1 NUMBER(6)DEPDATE1 DATEINTDATE1 DATE

    -----------------------------------------------------------------------------------------------------------------------1 declare2 sbno1 number(3);3 name1 varchar2(15);4 addr1 varchar2(15);5 balance1 number(6);6 interest1 number(4);7 total1 number(6);8 depdate1 date;9 intdate1 date;

    10 begin

    11 sbno1:=&sbno1;12 name1:='&name1';13 addr1:='&addr1';14 balance1:=&balance1;15 depdate1:=sysdate;16 interest1:=0;17 total1:=balance1;18 newacc(sbno1,name1,addr1,balance1,depdate1,interest1,total1,intdate1);19* end;

    SQL> /

    Enter value for sbno1: 5old 11: sbno1:=&sbno1;new 11: sbno1:=5;Enter value for name1: balajiold 12: name1:='&name1';new 12: name1:='balaji';Enter value for addr1: hyderabadold 13: addr1:='&addr1';new 13: addr1:='hyderabad';Enter value for balance1: 500old 14: balance1:=&balance1;new 14: balance1:=500;

    PL/SQL procedure successfully completed.

    13

  • 7/31/2019 Db&Wt Lab Manual

    14/38

    ------------------------------------------------------------------------------------------------------------------------SQL> select * from bank;

    SBNO1 NAME1 ADDR1 BALANCE1 INTEREST1 TOTAL1 DEPDATE1 NTDATE11 bavana chennai 2000 0 2000 03-MAY-07

    2 senthil bangalore 2000 0 2000 03-MAY-07

    3 bala chennai 2000 0 2000 03-MAY-07

    ------------------------------------------------------------------------------------------------------------------------1 create or replace procedure depositt(sbno2 number, balance2 number) is2 balance number(6);3 interest number(4);4 total number(6);5 begin6 select balance1, interest1, total1 into balance, interest, total from bank where sbno1=sbno2;

    7 balance:=balance+balance2;8 interest:=(balance2*0.02);9 total:=balance+interest;10 update bank set balance1=balance where sbno1=sbno2;11 update bank set interest1=interest where sbno1=sbno2;12 update bank set total1=total where sbno1=sbno2;13 update bank set intdate1=sysdate where sbno1=sbno2;14 end;15 .

    SQL>

    Procedure created.------------------------------------------------------------------------------------------------------------------------SQL>1 create or replace procedure withd(sbno2 number,balance2 number) is2 totalwith number(6);3 balancewith number(6);4 interest1 number(4);5 begin6 select balance1, total1, interest1 into balancewith, interest1, totalwith from bank where sbno17 if(totalwith-balance2)>500 then8 balancewith:=balancewith-balance2;

    9 interest1:=(balancewith*0.02);10 totalwith:=balancewith+interest1;11 update bank set balance1=balancewith where sbno1=sbno2;12 update bank set interest1=interest1 where sbno1=sbno2;13 update bank set total1=totalwith where sbno1=sbno2;14 update bank set intdate1=sysdate where sbno1=sbno2;15 else16 dbms_output.put_line('amount cant be withdrawn');17 end if;18 end;19 .

    SQL> /

    Procedure created.

    14

  • 7/31/2019 Db&Wt Lab Manual

    15/38

    ------------------------------------------------------------------------------------------------------------------------SQL> create or replace procedure delet(sbnod number) is2 begin3 delete from bank where sbno1=sbnod;4 end;5 .

    SQL>Procedure created.------------------------------------------------------------------------------------------------------------------------SQL>1 declare2 balance2 number(6);3 sbno2 number(3);4 choice varchar2(18);5 begin6 sbno2:=&sbno2;7 choice:='&choice';

    8 balance2:=&balance2;9 if choice='deposit' then10 depositt(sbno2,balance2);11 end if;12 if choice='withdraw' then13 withd(sbno2, balance2);14 end if;15 if choice='delete' then16 delet(sbno2);17 end if;18* end;

    SQL> /Enter value for sbno2: 2old 6: sbno2:=&sbno2;new 6: sbno2:=2;Enter value for choice: depositold 7: choice:='&choice';new 7: choice:='deposit';Enter value for balance2: 200old 8: balance2:=&balance2;new 8: balance2:=200;

    PL/SQL procedure successfully completed.------------------------------------------------------------------------------------------------------------------------SQL> /Enter value for sbno2: 3old 6: sbno2:=&sbno2;new 6: sbno2:=3;Enter value for choice: withdrawold 7: choice:='&choice';new 7: choice:='withdraw';Enter value for balance2: 7800old 8: balance2:=&balance2;new 8: balance2:=7800;

    PL/SQL procedure successfully completed.

    15

  • 7/31/2019 Db&Wt Lab Manual

    16/38

    ------------------------------------------------------------------------------------------------------------------------SQL> /Enter value for sbno2: 3old 6: sbno2:=&sbno2;new 6: sbno2:=3;Enter value for choice: withdrawold 7: choice:='&choice';new 7: choice:='withdraw';Enter value for balance2: 400old 8: balance2:=&balance2;new 8: balance2:=400;

    PL/SQL procedure successfully completed.-----------------------------------------------------------------------------------------------------------------------

    SQL> /Enter value for sbno2: 1

    old 6: sbno2:=&sbno2;new 6: sbno2:=1;Enter value for choice: deleteold 7: choice:='&choice';new 7: choice:='delete';Enter value for balance2: 0old 8: balance2:=&balance2;new 8: balance2:=0;

    PL/SQL procedure successfully completed.

    ------------------------------------------------------------------------------------------------------------------------

    SQL> select * from bank;

    SBNO1 NAME1 ADDR1 BALANCE1 INTEREST1 TOTAL1 DEPDATE1 INTDATE12 senthil bangalore 2200 4 2204 03-MAY-07 03-MAY-07

    3 bala chennai 2000 0 2000 03-MAY-07

    4 dfdf gdfgdfg 10 0 10 03-MAY-07

    5 balaji hyderabad 500 0 500 03-MAY-07

    -----------------------------------------------------------------------------------------------------------------------

    SQL>

    RESULT:

    Thus banking system, which allows users to operate savings and checking account usingPL/SQL statement executed successfully.

    16

  • 7/31/2019 Db&Wt Lab Manual

    17/38

    Ex. No : .5Date : / / 2007

    PAYROLL

    AIM:

    To implement payroll system, create database (table) and develop PL/SQLprocedure to demonstrate payroll database.

    ALGORITHM:

    Step 1: Start the program

    Step 2: Create a table payrolldb & employeedb

    Step 3: Insert data into the employeedb table.

    Step 4: Develop the PL/SQL statements to calculate resulted payrolldb databces.

    Step 5: Take input from the user for the given payroll database.

    Step 6: Print out with the necessary details.

    17

  • 7/31/2019 Db&Wt Lab Manual

    18/38

    SOURCE CODE:

    SQL> create table payrolldb(ename varchar2(15),basic number(6),hra number(6),cca number(6),dednumber(6),gross number(6),netpay number(6));

    Table created.

    SQL> desc payrolldb;Name Null? Type----------------------------------------- -------- ----------------------------ENAME VARCHAR2(15)BASIC NUMBER(6)HRA NUMBER(6)CCA NUMBER(6)DED NUMBER(6)GROSS NUMBER(6)NETPAY NUMBER(6)

    SQL> create table employeedb as select * from payrolldb;

    Table created.

    SQL> /

    PL/SQL procedure successfully completed.

    1 declare2 shra payrolldb.hra%type;

    3 scca payrolldb.cca%type;4 sded payrolldb.ded%type;5 snetpay payrolldb.netpay%type;6 sgross payrolldb.gross%type;7 emprec employeedb%rowtype;8 cursor emp_cursor is select * from employeedb;9 begin10 open emp_cursor;11 loop12 fetch emp_cursor into emprec;13 exit when emp_cursor%notfound;

    14 shra:=emprec.basic*.4;15 scca:=emprec.basic*.2;16 sgross:=emprec.basic+shra+scca;17 sded:=emprec.basic*.1;18 snetpay:=sgross-sded;19 insert into payrolldb values(emprec.ename,emprec.basic,shra,scca,sded,sgross,snetpay);20 end loop;21 commit work;22* end;

    SQL> /

    PL/SQL procedure successfully completed.

    SQL> /

    18

  • 7/31/2019 Db&Wt Lab Manual

    19/38

    PL/SQL procedure successfully completed.

    SQL> desc employeedb;Name Null? Type----------------------------------------- -------- ----------------------------ENAME VARCHAR2(15)BASIC NUMBER(6)HRA NUMBER(6)CCA NUMBER(6)DED NUMBER(6)GROSS NUMBER(6)NETPAY NUMBER(6)

    SQL> insert into employeedb values('&ename',&basic,&hra,&cca,&ded,&gross,&netpay);Enter value for ename: MANI

    Enter value for basic: 10000Enter value for hra: 4000Enter value for cca: 2000Enter value for ded: 1000Enter value for gross: 16000Enter value for netpay: 15000old 1: insert into employeedb values('&ename',&basic,&hra,&cca,&ded,&gross,&netpay)new 1: insert into employeedb values('MANI',10000,4000,2000,1000,16000,15000)

    1 row created.

    SQL> /Enter value for ename: BALAMURUGANEnter value for basic: 18000Enter value for hra: 6000Enter value for cca: 4000Enter value for ded: 2000Enter value for gross: 30000Enter value for netpay: 25000old 1: insert into employeedb values('&ename',&basic,&hra,&cca,&ded,&gross,&netpay)new 1: insert into employeedb values('BALAMURUGAN',18000,6000,4000,2000,30000,25000)

    1 row created.

    SQL> /Enter value for ename: SENTHIL KUMAREnter value for basic: 8000Enter value for hra: 6000Enter value for cca: 4000Enter value for ded: 1000Enter value for gross: 18000Enter value for netpay: 15000old 1: insert into employeedb values('&ename',&basic,&hra,&cca,&ded,&gross,&netpay)new 1: insert into employeedb values('SENTHIL KUMAR',8000,6000,4000,1000,18000,15000)

    1 row created.

    19

  • 7/31/2019 Db&Wt Lab Manual

    20/38

    SQL> declare2 shra payrolldb.hra%type;3 scca payrolldb.cca%type;4 sded payrolldb.ded%type;5 snetpay payrolldb.netpay%type;6 sgross payrolldb.gross%type;7 emprec employeedb%rowtype;8 cursor emp_cursor is select * from employeedb;9 begin10 open emp_cursor;11 loop12 fetch emp_cursor into emprec;13 exit when emp_cursor%notfound;14 shra:=emprec.basic*.4;15 scca:=emprec.basic*.2;16 sgross:=emprec.basic+shra+scca;

    17 sded:=emprec.basic*.1;18 snetpay:=sgross-sded;19 insert into payrolldb values(emprec.ename,emprec.basic,shra,scca,sded,sgross,snetpay);20 end loop;21 commit work;22 end;23 .

    SQL> /

    PL/SQL procedure successfully completed.

    SQL> SELECT * FROM EMPLOYEEDB;

    ENAME BASIC HRA CCA DED GROSS NETPAY-----------------------------------------------------------------------------------------------------------MANI 10000 4000 2000 1000 16000 15000BALAMURUGAN 18000 6000 4000 2000 30000 25000SENTHIL KUMAR 8000 6000 4000 1000 18000 15000

    SQL> SELECT * FROM PAYROLLDB;

    ENAME BASIC HRA CCA DED GROSS NETPAY-----------------------------------------------------------------------------------------------------------MANI 10000 4000 2000 1000 16000 15000BALAMURUGAN 18000 7200 3600 1800 28800 27000SENTHIL KUMAR 8000 3200 1600 800 12800 12000

    RESULT:

    Thus payroll system was implemented, database (table) was created and PL/SQLProcedure was developed to demonstrate payroll database.

    20

  • 7/31/2019 Db&Wt Lab Manual

    21/38

    Ex. No: 6Date : / / 2007

    Web Page Creation Using Form Controls

    AIM :

    To implement web page information, develop HTML program to required webpage form.

    ALGORITHM:

    Step 1: Start the program

    Step 2: Open appropriate software to develop html code.

    Step 3: Develop a HTML and DHTML program for required web page.

    Step 4: Design a web page format to accept user purchase details.

    Step 5: Take input from the user for the given web page.

    Step 6: Print out with the necessary details.

    21

  • 7/31/2019 Db&Wt Lab Manual

    22/38

    SOURCE CODE:

    Order formDesigning a web Page using HTML, DHTML and Client-side Script

    #a{color:green;font-size:25;text-decoration:underline}.a{color:red;font-size:15;font-style:italic}

    function rate_display(){

    if(frm.book.options[0].selected)document.frm.ratetxt.value = "$"else if(frm.book.options[1].selected)document.frm.ratetxt.value = "250"

    else if(frm.book.options[2].selected)document.frm.ratetxt.value = "500"

    else if(frm.book.options[3].selected)document.frm.ratetxt.value = "150"

    else if(frm.book.options[4].selected)document.frm.ratetxt.value = "100"

    else if(frm.book.options[5].selected)document.frm.ratetxt.value = "130"

    else if(frm.book.options[6].selected)document.frm.ratetxt.value = "170"

    }function tot_price(){

    var rt, nofbooks, totamt

    rt = parseInt(frm.qty.options[frm.qty.selectedIndex].value)nofbooks = parseInt(document.frm.ratetxt.value)totamt = rt * nofbooksdocument.frm.totxt.value = totamt

    }

    Welcome to Online Book ShoppingSelect the name of the book first, then Select the number of copies per each book


    22

  • 7/31/2019 Db&Wt Lab Manual

    23/38

    Book Name Quantity Rate per one book

    ----select a book------ Java Complete ReferenceProfessional JSP

    HTML in 21 daysComputer NetworksComputer ArchitectureCompiler Design

    123

    45


    Total Price:

    23

  • 7/31/2019 Db&Wt Lab Manual

    24/38

    OUTPUT:

    RESULT:

    Thus a web page was designed using HTML, DHTML and Client side Script (JavaScript)..

    24

  • 7/31/2019 Db&Wt Lab Manual

    25/38

    Ex. No : .7Date : / / 2007

    Date Time Server

    AIM:

    To implement Date and Time server which would give current date andtime to the requesting client program using JAVA.

    ALGORITHM:

    Step 1: Start the program

    Step 2: Create a server using ServerSocket also define the port which listens for clientrequest.

    Step 3: When request arrived, send the current date and time to the client usingSocket.

    Step 4: Similarly, create client using ServerSocket and a port through which itreceives the response from the server.

    Step 5: When request arrived at client, read the arrived date and time, and display the output.

    Step 6: Now terminate both client and server program.

    25

  • 7/31/2019 Db&Wt Lab Manual

    26/38

  • 7/31/2019 Db&Wt Lab Manual

    27/38

    OUTPUT:

    RESULT:

    Thus a program to implement Date and Time server which would give current date andtime to the requesting client program using JAVA was executed successfully.

    27

  • 7/31/2019 Db&Wt Lab Manual

    28/38

    Ex. No : .8Date : / / 2007

    JAVA DATABASE CONNECTIVITY

    AIM:To access the student details stored in a database using JDBC connectivity in java

    ALGORITHM:

    Step 1: Start the program

    Step 2: Create a Java program, then define the JDBC connectivity using Class andconnection.

    Step 3: Crate databases screen like ADD, DELETE, PREV & NEXT using HTML codeand access data from the user.

    Step 4: Now create a query using execute query statement.

    Step 5: The result set is stored in a ResultSet object.

    Step 6: Take input from the user for the given web page.

    Step 7: Print out with the necessary details.

    28

  • 7/31/2019 Db&Wt Lab Manual

    29/38

    SOURCE CODE

    import java.sql.*;public class Database1{

    public static void main(String arg[]) throws Exception{String query ="select * from emp";System.out.println("The Query is: "+ query + "\n");

    try{

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");Connection con=DriverManager.getConnection("jdbc:odbc:empdsn","","");Statement sm=con.createStatement();

    ResultSet rs=sm.executeQuery(query);System.out.println("ENO\t\t"+"ENAME\t\t"+"SALARY");

    while(rs.next()){

    System.out.println(rs.getInt("Eno")+"\t\t"+rs.getString("Ename")+"\t\t"+rs.getFloat("sal"));

    }sm.close();con.close();

    }catch(Exception e){}

    }}

    29

  • 7/31/2019 Db&Wt Lab Manual

    30/38

    OUTPUT:

    RESULT :

    Thus the student details stored in a database were accessed using JDBC connectivity in java

    30

  • 7/31/2019 Db&Wt Lab Manual

    31/38

    Ex. No : .9Date : / / 2007

    JSP Program for Order Processing

    AIM:

    To implement order processing using a JSP program.

    ALGORITHM:

    1. Design a web page for view and place order to a particular company.

    2. Provide the link get the stock details of the particular company.

    3. Get the stock details from database using JSP program

    4. Display the stock details of the company after enabling the link.

    5. Place the order for the particular product.

    6. Process the order using JSP program, which satisfies necessary condition (Invalid item,

    insufficient qty etc).

    7. Display the final messages

    31

  • 7/31/2019 Db&Wt Lab Manual

    32/38

    SOURCE CODE:

    Link1.html

    ABC COMPANY

    VIEW STOCK DETAILS

    PLACE ORDER

    ITEM NO

    QTY

    stock.jsp

  • 7/31/2019 Db&Wt Lab Manual

    33/38

    while(rs.next()){out.println(""+rs.getInt(1));out.println(""+rs.getString(2));out.println(""+rs.getInt(3));out.println(""+rs.getInt(4)+"");}out.println("");

    out.println("

    Back to purchase form");%>

    order.jsp

  • 7/31/2019 Db&Wt Lab Manual

    34/38

    if(rs.getInt(3)>=k2){

    stmt.executeUpdate("update johnson set qty=qty-"+k2+" where itemno="+k1);out.println("Thank you for purchasing.The order will be delivered in 2 days");out.println("
    The ITEM NO : "+k1);out.println("
    The PRODUCT NAME : "+ss);out.println("
    The Qty Placed : "+k2);out.println("
    The RATE PER QTY Rs.: "+ii);out.println("
    The ToTAL PRICE IS Rs.: "+tot);

    }else

    out.println("Required Stock is not available");}

    if(count==0)out.println("Invalid Item");

    }

    }catch(Exception e)

    {System.out.println(e);}

    %>

    34

  • 7/31/2019 Db&Wt Lab Manual

    35/38

    OUTPUT:

    RESULT:

    Thus JSP program is implemented to process the order.

    35

  • 7/31/2019 Db&Wt Lab Manual

    36/38

    Ex. No: 10Date : / / 2007

    ASP Component

    AIM:To create a Browser component using ASP.

    ALGORITHM:

    Step 1 : Open an ASP file

    Step 2 : Declare the script language as VBScript

    Step 3 : Create a built-in object called BrowserType

    Step 4 : Use the BrowserType object and display all browser properties

    36

  • 7/31/2019 Db&Wt Lab Manual

    37/38

    SOURCE CODE:

    37

  • 7/31/2019 Db&Wt Lab Manual

    38/38

    OUTPUT:

    RESULT:

    Thus a browser component was created to demonstrate an ASP component.