Skip to main content

Posts

Showing posts from January, 2013

Generate Sqare Matrix: HTML & jScript

<html> <head>     <script>         function mktab(a)         {             var i=1;             var j=1;             var cnt=1;                        document.write("<center><table border=0 bordercolor=black style='color:white;font-size:25'>");             for(i=1;i<=a;i++)             {                 document.write("<tr border=0>")                 for(j=1;j<=a;j++)                 { document.write("<td bgcolor=rgb("+(i+50)+","+(j+50)+","+i+")>*</td>");                     cnt=cnt+1;                 }                 document.write("</tr>");             }             document.write("</table></center>");         }     </script> </head> <body>     <center>         Enter Matrix<sup><B>SQUARE</B></sup> limit  : <input type="text" id="t1"/>         <in

Sample: Oracle Create, Update, Insert, Triggers, Cursors, Procedures

/* IGNOU MCA SOLVED QUESTION PAPER MCSL-045 DEC-2012*/ create table Sales_Person  (S_id number, S_name varchar2(30), Experience number, S_Designation varchar2(30), S_product varchar2(30)); create table Sales_Record  (S_id number, S_target number, S_sold number, S_order number); create table Sales_Salary  (S_id number, S_basic number, S_grade number, S_salary number); /* A trigger for auto update SALARY */ CREATE OR REPLACE TRIGGER CL_SALARY  AFTER INSERT OR DELETE OR UPDATE ON Sales_Person BEGIN     UPDATE SALES_SALARY SET S_SALARY=S_BASIC+S_GRADE; END CL_SALARY; INSERT INTO Sales_Person VALUES(5, 'TUHIN SUMANTA', 30,'MANAGER','COSMETICS'); INSERT INTO Sales_Record VALUES(4,70,65,22); INSERT INTO SALES_SALARY VALUES(5,7850,500,0); UPDATE SALES_SALARY SET S_SALARY=S_BASIC+S_GRADE; SELECT * FROM SALES_PERSON; SELECT * FROM SALES_RECORD; SELECT * FROM SALES_SALARY; /* Creating View with JOIN */ CREATE OR REPLACE VIEW S_VIEW_EX 

UNIX Commmand & their featurs

Unix Commands General Commands ls – (List Schema) This command will list the contents of your current directory. It only returns files that are not (.) "dot" files. mkdir - (Make Directory). With this command will create a subdirectory in your home directory. cd - (Change Directory) With this command you can move from your current working directory to a new directory. pwd - (Print Working Directory). The pwd command, when evoked, will display the absolute pathname for the directory you are currently in.. cp – (copy). This command will copy a file from one directory to another. mv – (Move) this allows you to move a file from one place to another rm - (Remove) This command is used to delete a file. rmdir – (Remove Directory) This command is used to delete directories. clear - Clear the terminal window. cat – (Concatenate) Can be used to display the contents of a file on the screen. more – The more command is used to view files ju

Oracle Triggers

/*ADDING NEW ROW BY TRIGGER  /*ORACLE 9i SCOTT/TIGER  /* TRIGGERED ON EMP TABLE /*CREATING NEW TABLE WHICH WILL UPDATED BY TRIGGERED */ CREATE TABLE DEPT_SUMMARY ( DEPTNO NUMBER, AVG_SALARY NUMBER, NO_OF_EMP NUMBER ); create or replace TRIGGER TG_EMP_SAL_SUMMARY AFTER INSERT OR DELETE OR UPDATE ON EMP DECLARE   CURSOR CUR_EMP   IS     SELECT COUNT(ENAME),SUM(SAL),DEPTNO FROM EMP GROUP BY DEPTNO;     V_CNT NUMBER;     V_SAL EMP.SAL%TYPE:=0;     V_DEPT EMP.DEPTNO%TYPE:=0; BEGIN   DELETE DEPT_SUMMARY;   OPEN CUR_EMP;     LOOP       FETCH CUR_EMP INTO V_CNT,V_SAL,V_DEPT;       EXIT WHEN NOT CUR_EMP%FOUND;       INSERT INTO DEPT_SUMMARY       VALUES(V_DEPT,V_SAL/V_CNT,V_CNT);     END LOOP; END TG_EMP_SAL_SUMMARY; /*INSERTING NEW ROW INTO EMP*/ INSERT INTO EMP VALUES(100,'DIBYENDU','ADMIN',15,'12-JAN-00',6580,250,20); /*OUTPUT ON DEPT_SUMMARY TABLE DEPTNO AVG_SALARY NO_OF_EMP 10 2916.66667 3 20 3204.375 8 30 15

Oracle 9i Cursor Implementation Demo.

/*Fetch Every Employee Details With the help of cursor*/ /*DBMS:SCOTT/TIGER:ORACLE 9i*/ SET SERVEROUTPUT ON DECLARE   VEMPNO EMP.EMPNO%TYPE;   VENAME EMP.ENAME%TYPE;   VSAL EMP.SAL%TYPE;   CURSOR CR_EMP   IS   SELECT EMPNO,ENAME,SAL FROM EMP; BEGIN   OPEN CR_EMP;   LOOP     FETCH CR_EMP INTO VEMPNO,VENAME,VSAL;   EXIT WHEN CR_EMP%NOTFOUND;     DBMS_OUTPUT.PUT_LINE('EMPLOYEE DETAILS');      DBMS_OUTPUT.PUT_LINE('----------------');     DBMS_OUTPUT.PUT_LINE('ID: '||VEMPNO);     DBMS_OUTPUT.PUT_LINE('NAME: '||VENAME);     DBMS_OUTPUT.PUT_LINE('BASIC: '||VSAL);     DBMS_OUTPUT.PUT_LINE('----------------');   END LOOP;   CLOSE CR_EMP; END; OR /*Fetch Every Employee Details With the help of cursor*/ /*DBMS:SCOTT/TIGER:ORACLE 9i*/ /*WHILE LOOP*/ SET SERVEROUTPUT ON DECLARE   VEMPNO EMP.EMPNO%TYPE;   VENAME EMP.ENAME%TYPE;   VSAL EMP.SAL%TYPE;   CURSOR CR_EMP   IS   SELECT EMPNO,ENAME,SAL FROM EMP; BEGIN

Oracle Cursor

/*Fetch Every Employee Details With the help of cursor*/ /*DBMS:SCOTT/TIGER:ORACLE 9i*/ SET SERVEROUTPUT ON DECLARE   VEMPNO EMP.EMPNO%TYPE;   VENAME EMP.ENAME%TYPE;   VSAL EMP.SAL%TYPE;   CURSOR CR_EMP   IS   SELECT EMPNO,ENAME,SAL FROM EMP; BEGIN   OPEN CR_EMP;   LOOP     FETCH CR_EMP INTO VEMPNO,VENAME,VSAL;   EXIT WHEN CR_EMP%NOTFOUND;     DBMS_OUTPUT.PUT_LINE('EMPLOYEE DETAILS');      DBMS_OUTPUT.PUT_LINE('----------------');     DBMS_OUTPUT.PUT_LINE('ID: '||VEMPNO);     DBMS_OUTPUT.PUT_LINE('NAME: '||VENAME);     DBMS_OUTPUT.PUT_LINE('BASIC: '||VSAL);     DBMS_OUTPUT.PUT_LINE('----------------');   END LOOP;   CLOSE CR_EMP; END; OR /*Fetch Every Employee Details With the help of cursor*/ /*DBMS:SCOTT/TIGER:ORACLE 9i*/ /*WHILE LOOP*/ SET SERVEROUTPUT ON DECLARE   VEMPNO EMP.EMPNO%TYPE;   VENAME EMP.ENAME%TYPE;   VSAL EMP.SAL%TYPE;   CURSOR CR_EMP   IS   SELECT EMPNO,ENAME,SAL FROM EMP; BEGIN

Oracle Cursor

/*Fetch Every Emloyee Details With the help of cursor*/ /*DBMS:SCOTT/TIGER:ORACLE 9i*/ SET SERVEROUTPUT ON DECLARE   VEMPNO EMP.EMPNO%TYPE;   VENAME EMP.ENAME%TYPE;   VSAL EMP.SAL%TYPE;   CURSOR CR_EMP   IS   SELECT EMPNO,ENAME,SAL FROM EMP; BEGIN   OPEN CR_EMP;   LOOP     FETCH CR_EMP INTO VEMPNO,VENAME,VSAL;   EXIT WHEN CR_EMP%NOTFOUND;     DBMS_OUTPUT.PUT_LINE('EMPLOYEE DETAILS');      DBMS_OUTPUT.PUT_LINE('----------------');     DBMS_OUTPUT.PUT_LINE('ID: '||VEMPNO);     DBMS_OUTPUT.PUT_LINE('NAME: '||VENAME);     DBMS_OUTPUT.PUT_LINE('BASIC: '||VSAL);     DBMS_OUTPUT.PUT_LINE('----------------');   END LOOP;   CLOSE CR_EMP; END; OR /*Fetch Every Emloyee Details With the help of cursor*/ /*DBMS:SCOTT/TIGER:ORACLE 9i*/ /*WHILE LOOP*/ SET SERVEROUTPUT ON DECLARE   VEMPNO EMP.EMPNO%TYPE;   VENAME EMP.ENAME%TYPE;   VSAL EMP.SAL%TYPE;   CURSOR CR_EMP   IS   SELECT EMPNO,ENAME,SAL FROM EMP; BEGIN  

Oracle Procedure

/*CREATING PROCEDURE /*DBMS:SCOTT/TIGER:ORACLE 9i*/ create or replace PROCEDURE addNewEmp( VEMPNO EMP.EMPNO%TYPE, VENAME EMP.ENAME%TYPE, VJOB EMP.JOB%TYPE, VMGR EMP.MGR%TYPE, VHIREDATE EMP.HIREDATE%TYPE, VSAL EMP.SAL%TYPE, VCOMM EMP.COMM%TYPE, VDEPTNO EMP.DEPTNO%TYPE) AS  BEGIN    INSERT INTO EMP(EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO)    VALUES(VEMPNO,VENAME,VJOB,VMGR,VHIREDATE,VSAL,VCOMM,VDEPTNO);  END addNewEmp; /*EXECUTING PROCEDURE BEGIN   addNewEmp(7999,'DIBYENDU','ANALYST',9999,'03-JAN-2008',25700,1250,30); END;