Sie sind auf Seite 1von 9

Join us on Facebook Page http://www.facebook.

com/ignousolution

PART-I: UNIX Lab


(a) Perform the following in UNIX operating system using the UNIX commands: (i) Find the number of users that are presently logged in to your system. You must count them using UNIX command only. Hint:- #who |wc -l (ii) Create three files with at least a paragraph of text. Print these three files using minimum number of UNIX commands. Hint:#touch file1 file2 file3 #echo " file content" > file1 #cat file1 #cat file2 #cat file3 # lpr file1 file2 file3 or lpr file* (iii) Create a directory. Change its permission to Read only. Now try to copy a file in this directory. Record the outcome of the operation and explain it. Hint:#mkdir /dirname #chod 444 /dainame #cp file /dirname (iv) Create a file having some text. Copy its content to another file. Edit at least two lines of the copied file. Now use UNIX command to display the difference between the two files. Explain the result so obtained. Hint:# cp data_file another_file # echo "new line for another_file" >> another_file # echo "one more new line for another_file" >> another_file # diff date_file another_file (v) Change the command prompt to % and then restore the original command prompt. Hint:# PS1=%;export PS1 --- it change is temprary. # exit --- for restore (vi) Find the number of files in you directory. Hint:- ls -l . | egrep -c '^-' ls -l | grep ^- | wc -l ----(for files) ls -l | grep ^d | wc -l ----(for directory) ls -l | grep ^l | wc -l ----(for links)

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Join us on Facebook Page http://www.facebook.com/ignousolution


b) Perform the following tasks using grep. You may use additional commands, if needed: (i) Count the number of blank lines of a file. Hint:- grep "^$" file_name |wc -l (ii) Display all those lines in a file that has only upper case characters. Hint:# cat filename | grep '^[A-Z]*$' (iii) Select all those lines that has a ? at the end of the line. cat filename | grep ? (iv) Select all those lines which has any of the followijg patterns ab aab aaab or like wise Hint:# cat file_name|egrep "ab|like wise" Question 2: (a) Write a shell program that converts all the alphabets in a file to uppercase alphabets and displays the trHintlated file on the screen. Hint:#!/bin/bash # get filename echo -n "Enter File Name : " read fileName # make sure file exits for reading if [ ! -f $fileName ]; then echo "Filename $fileName does not exists" exit 1 fi # convert to lowercase using tr command tr '[a-z]' '[A-Z]' < $fileName (b) Write a shell program that counts the occurrences of the complete word MCA in a file. Hint:#!/bin/ksh typeset -i mCnt=0 mWord='aaa' for mEach in `cat input_file` do if [ "${mEach}" = "${mWord}" ]; then mCnt=${mCnt}+1 fi done echo 'Total words for '${mWord}' = '${mCnt}

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Join us on Facebook Page http://www.facebook.com/ignousolution


(c) Write a shell program that outputs all odd integers up to the command line parameter starting from 1. Hint:#include <iostream> #include <fstream> using namespace std; int main() { ifstream fin("numbers.txt"); ofstream fout("odd.txt"); //check for possible errors if (fin. fail()) { cerr << "could not open input file numbers.txt\n"; } if (fout. fail()) { cerr << "could not open output file odd.txt\n"; } int x; fin >> x; while (!fin.eof()) { if (x % 2 ==1) { fout << x << " " << endl; } else { cerr << "Even number" << x << " " << endl; } } fin.close(); fout.close(); return 0; }

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Join us on Facebook Page http://www.facebook.com/ignousolution

PART-II: DBMS Lab


Hint a : CREATE TABLE Company ( CompanyID NUMBER NOT NULL , CompanyName VARCHAR2(50) NULL , Owner VARCHAR2(50) NULL , Address1 VARCHAR2(70) NULL , Address2 VARCHAR2(70) NULL , CityID NUMBER NULL , StateID NUMBER NULL , Pincode VARCHAR2(10) NULL , Email VARCHAR2(30) NULL , Web VARCHAR2(30) NULL , Phone1 VARCHAR2(20) NULL , Phone2 VARCHAR2(20) NULL , TAN No VARCHAR2(20) NULL , CreatedDateTime Date, UpdateDateTime Date, CONSTRAINT PK_COMPANY PRIMARY KEY (CompanyID) ); CREATE TABLE Supplier ( SupplierID NUMBER NOT NULL , SupplierCode VARCHAR2(50) NULL , SupplierName VARCHAR2(50) NULL , Address1 VARCHAR2(50) NULL , Address2 VARCHAR2(50) NULL , CityID NUMBER NULL , StateID NUMBER NULL , Pincode VARCHAR2(10) NULL , Email VARCHAR2(30) NULL , Web VARCHAR2(30) NULL , Phone1 VARCHAR2(30) NULL , Phone2 VARCHAR2(30) NULL , CreatedDateTime Date, UpdateDateTime Date, CONSTRAINT PK_Supplier PRIMARY KEY (SupplierID) ); CREATE TABLE Customer ( CustomerID NUMBER NOT NULL , CustomerCode VARCHAR2(50) NULL , CustomerName VARCHAR2(50) NULL , Address1 VARCHAR2(50) NULL , Address2 VARCHAR2(50) NULL , CityID NUMBER NULL , StateID NUMBER NULL , Pincode VARCHAR2(10) NULL , Email VARCHAR2(30) NULL , Web VARCHAR2(30) NULL ,

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Join us on Facebook Page http://www.facebook.com/ignousolution


Phone1 VARCHAR2(30) NULL , Phone2 VARCHAR2(30) NULL ,

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Join us on Facebook Page http://www.facebook.com/ignousolution


IsWalkInCustomer CHAR(1) , CreatedDateTime Date, UpdateDateTime Date, CONSTRAINT PK_Customer PRIMARY KEY (CustomerID) ); CREATE TABLE City ( CityID NUMBER NOT NULL , CityName VARCHAR2(50) NULL , CreatedDateTime Date, UpdateDateTime Date, CONSTRAINT PK_City PRIMARY KEY (CityID) ); CREATE TABLE State ( StateID NUMBER NOT NULL , StateName VARCHAR2(50) NULL , CreatedDateTime Date, UpdateDateTime Date, CONSTRAINT PK_State PRIMARY KEY (StateID) ); CREATE TABLE Category ( CategoryID NUMBER NOT NULL , CategoryName VARCHAR2(50) NULL , CreatedDateTime Date, UpdateDateTime Date, CONSTRAINT PK_Category PRIMARY KEY (CategoryID) ); CREATE TABLE Product ( ProductID NUMBER NOT NULL , ProductCode VARCHAR2(50) NOT NULL , ProductName VARCHAR2(50) NOT NULL , CategoryID NUMBER NOT NULL , BatchNumber VARCHAR2(50) NULL , CostPrice float SellingPrice float SupplierID NUMBER NOT NULL , StockQuantity NUMBER NULL , ReOrderLevelQty NUMBER NULL , IsReorder Char(1), IsExpired Char(1), ExpiryDate date, CreatedDateTime date, UpdateDateTime date, CONSTRAINT PK_Product PRIMARY KEY (ProductID) ); CREATE TABLE PurchaseOrder (

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Join us on Facebook Page http://www.facebook.com/ignousolution


PurchaseOrderID NUMBER NOT NULL , SupplierID NUMBER NOT NULL, PONo VARCHAR2(50) NOT NULL , PODate date, Amount float NULL, CreatedDateTime date, UpdateDateTime date, CONSTRAINT PK_PurchaseOrder PRIMARY KEY (PurchaseOrderID) ); CREATE TABLE PurchaseOrderDetail ( PurchaseOrderDetailID NUMBER NOT NULL , PurchaseOrderID NUMBER NOT NULL , ProductID NUMBER NOT NULL , Quantity Number NULL, Rate float NULL, CreatedDateTime date, UpdateDateTime date, CONSTRAINT PK_PurchaseOrderDetail PRIMARY KEY (PurchaseOrderDetailID) ); CREATE TABLE Sales ( SalesID NUMBER NOT NULL , SalesDate Date Not Null, CustomerID NUMBER NOT NULL , Amount float NULL, Discount float NULL, CreatedDateTime date, UpdateDateTime date, CONSTRAINT PK_Sales PRIMARY KEY (SalesID) ); CREATE TABLE SalesDetails ( SalesDetailID NUMBER NOT NULL , SalesID NUMBER NOT NULL , ProductID NUMBER NOT NULL , Quantity Number NULL, Rate float NULL, CreatedDateTime date, UpdateDateTime date, CONSTRAINT PK_SalesDetails PRIMARY KEY (SalesDetailID) ); ALTER TABLE CITY ADD CONSTRAINT FK_CITY_CITYID FOREIGN KEY (CITYID) REFERENCES SUPPLIER(CITYID); ALTER TABLE CITY ADD CONSTRAINT FK_CITY_CITYID FOREIGN KEY (CITYID) REFERENCES CUSTOMER(CITYID);

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Join us on Facebook Page http://www.facebook.com/ignousolution


ALTER TABLE STATE ADD CONSTRAINT FK_STATE_STATEID FOREIGN KEY (STATEID) REFERENCES SUPPLIER(STATEID); ALTER TABLE STATE ADD CONSTRAINT FK_STATE_STATEID FOREIGN KEY (STATEID) REFERENCES CUSTOMER(STATEID); ALTER TABLE PRODUCT ADD CONSTRAINT FK_PRODUCT_CATEGORYID FOREIGN KEY (CATEGORYID) REFERENCES CATEGORY(CATEGORYID); ALTER TABLE PURCHASEORDERDETAIL ADD CONSTRAINT FK_PURCHASEORDERDETAIL_PURCHASEORDERDETAILID FOREIGN KEY (PURCHASEORDERDETAIL) REFERENCES PURCHASEORDER(PURCHASEORDERDETAIL); ALTER TABLE SALESDETAILS ADD CONSTRAINT FK_SALESDETAILS_PURCHASEORDERDETAILID FOREIGN KEY (SALESID) REFERENCES SALES(SALESID); Hint b: (i) SELECT * FROM Product WHERE ExpiryDate BETWEEN SYSDATE AND (SYSDATE+10); (ii) Select S.SupplierName as "Price" From PurchaseOrderDetail AS POD Inner join PurchaseOrder as PO On POD.PurchaseOrderID = PO.PurchaseOrderID Inner join Supplier as S On S.SupplierID = PO.SupplierID Inner join Product as P On P.ProductID = POD.ProductID where POD.ProductName = 'Pen' and PO.PODate >= SysDate - 365 and Rownum<=1 Group by S.SupplierName Order by Min(Rate) ; (iii) Select SupplierName From Supplier Where SupplierID NOT IN (Select SupplierID from PurchaseOrder Where PO.PODate >= SysDate - 365 ); (iv) Select C.CategoryName,P.ProductName from Category as C inner join Product as P On P.CategoryID = C.P.CategoryID Order by C.CategoryName,P.ProductName; Hint c: CREATE OR REPLACE VIEW VW_SALES AS SELECT * FROM sales inner join SALESDETAILS on sales.salesid = salesdetails.salesid;

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Join us on Facebook Page http://www.facebook.com/ignousolution


GRANT SELECT, INSERT ON VW_SALES TO STOREMANAGER; CREATE OR REPLACE VIEW VW_SALESDETAILS AS SELECT * FROM sales inner join SALESDETAILS on sales.salesid = salesdetails.salesid; GRANT SELECT ON VW_SALESDETAILS TO SALESPERSON; Hint d: Create or Replace Proc AvgCostPrice as BEGIN Select Avg(CostPrice) as AvgCostPrice from Product; END; Hint e: CREATE OR REPLACE PROCEDURE SP_UPDATESTOCK AS BEGIN BEGIN Insert into Sales Values(1,'05-Jan-2011',101,740.00,0,'11/11/2011',NULL); SAVEPOINT my_savepoint; Insert into SalesDetails Values(1,1,1,4,10.00,'11/11/2011',NULL); Insert into SalesDetails Values(2,1,10,4,50.00,'11/11/2011',NULL); Insert into SalesDetails Values(3,1,20,50,10.00,'11/11/2011',NULL); SAVEPOINT my_savepoint; EXCEPTION WHEN OTHERS THEN ROLLBACK TO my_savepoint; DBMS_OUTPUT.PUT_LINE('TrHintaction rolled back.'); END; Hint f: (i) CREATE OR REPLACE TRIGGER TrigProduct AFTER UPDATE ON Product AS BEGIN update Product SET ISREORDER = 'Y' WHERE StockQuantity <= ReOrderLevelQty; END; SELECT * FROM PRODUCTMASTER WHERE ISREORDER = 'Y'; (ii) CREATE OR REPLACE TRIGGER TrigGetProductStatus AFTER UPDATE ON Product AS BEGIN SELECT * FROM PRODUCTMASTER WHERE IsExpired = 'Y';

For more info visit http://everythingsolution.blogspot.com/


END;

Join us also on our Group http://www.facebook.com/groups/solvedassignment/

Das könnte Ihnen auch gefallen