March 2011

3 Popular Open Source Version Control Systems - Mercurial HG, SVN and CVS

In the project development, it is most needed one to maintain the project source. Version control system helps to keep track of the source code history by using changeset or revision.

Why we need version control System

It is vital tool in the project development area. It helps to backup the project code. while working in project if something went really worst due to the change, we can get the previous version code.

Each commit or change to repository is called changeset or revision. Using this we could go back to any previous code. Developers of the project can work parallely in their own area and merge the changes.

It helping to branch the code, for example you are all working for project fixes, and one of the developer working in new architecture model to implement it later point of time. So at the later point this can be integrated / mergerd with latest. The branching helps for this.

What normal operations we do in repository?

  • Import your initial project code to repository.
  • Take a copy of the code from repository.
  • Make changes to the code.
  • Commit your changes.
  • If any conflict occurs then resolve it or merge it.
  • Naming the release like tagging.

Most Popular Opensource Versioning Systems are

    1. CVS (Concurrent  Versions System
    2. SVN (Subversion Version control system)
    3. Mercurial HG

The below section, we just get overall points about these open source version control systems.

CVS

This the oldest among these three version control system. It is widely used version control system.

It mainly developed to store text files. We can store other file formats also which needs special information to be passed to cvs.

for example to store the binary files, we have to tell the cvs that it is binary file by using flag.

   cvs add -kb filename

We can set up the apache server to access the repository in browser. CVS have rollback option, if we commit something wrong then using rollback, we can remove it from repository.

CVS using file system storage to keep track the changes of the file.

Basic CVS Commands

Before start using the CVS, we have to export CVSROOT that is where the cvs server locates.
cvs import project - To add new project into CVS.

cvs add - You can add new files.
cvs commit - To commit changes.

cvs update - To get the changes from CVS.
cvs tag used to tag the code for release.

cvs log - to see the all the version log messages.

cvs diff - to see the difference betwen local and repository or between version changes.

cvs status - to see the status of working file. ?- new file added in local , R - file removed in local, M-file modified in working area.

SVN

SVN removes the drawbacks of the CVS. In CVS if we commit and it interupts in the middle then the cvs becomes unstable. SVN overcomes this by the automic commits, either all the files get committed or none of them. So it gives neat and clean repository always.It is using revision to support the automic commit.

In addition with automic commits, it supports native binary file formats, version control for symbolic links and provide fast tagging. In SVN, we can rename or move files and directory with its history.

We can set up the apache server to access the repository in browser, which CVS also provides but it is easier than CVS.

Like CVS, if we commit something wrong, we can't rollback here. That wrong code exists in the repository.

Basic SVN Commands

If you know the CVS commands then it is almost same for SVN also.
    svn import - to import new project to repository.
    svn add - to add files, directories and symbolic links to repositoy.
    svn checkout - to get working copy to local.
    svn commit - commit the changes from local to repository.
    svn diff - to see the difference between revisions or local to repository.
    svn status - to see the status of the file.
    svn log - shows the log messages

Mercurial

Recent days the Mercurial HG is used widely since it is using distributed model, opensource system and having good documentation.

It is also have fast taging , support of binary files, it uses changeset for each commit so the repository is stable.

At any point of time, the changeset revision helps to get any revision. We can work in local area without connecting the repository eachtime, since it is distributed model. We can commit the changes to local machine and push to central repository.

Like CVS and SVN, in mercurial also we can set up apache and browse the repository using http or https

Basic Commands in Mercurial HG

   1. hg init projectname - To create new project.

   2. hg add filename - To add files to commit

   3. hg commit filename ... - To commit files

   4. hg push - To push the committed files to repository

   5. hg clone - To take copy of repository to work locally

   6. hg pull - To get the latest code to working directory

   7. hg update - To update the pulled files or can use to switch between revisions

   8. hg status filename - To check the status of the file,
    ? - New file
    M - Modified
    R - removed

   9. hg diff filename - To see the difference between local file and repository.
   To see the difference between two revisions.

   hg diff -r rev1 -r rev2 filename.

   10. hg log - To display all the revsions till date. If file name specified, it show the revision of that particular file.

   11. hg identify - To know currently in which revision.

   12. hg branch - To get the branch name

   13. hg tag tagname - To tag it before release so it can be referred easily.

    You can get the particular release by hg update tagname

    hg tags to get all the tags.

   14. hg remove filename - To remove specific file.

   15. hg merge - To merge changes

To summarize, the CVS is the oldest and till used widely. SVN provides additional features and most of the open source projects are moved from CVS to SVN. The Mercurial is the latest and distributed model and having good documentations. You can easily setup sending the changes in mail to intimate other users about your changes.

Unless something stopping to move to the latest revision control system, you move easily to Mercurial and enjoy the features.

DB2 Basics and COBOL with DB2

DB2 is the one of the relation database management system developed by the IBM. This is similar to other RDBMS like Oracle, MySQL , SQL Server.

What is DDL, DCL, DML and TCL:

DCL (Data Control Language) commands used to set the privileges like GRANT, REVOKE

DDL (Data Definition Language) used to define the structure like CREATE, ALTER, TRUNCATE,DROP

DML (Data Manipulation Language) used to manage the data like SELECT, INSERT, DELETE, UPDATE.

TCL (Transaction Control Language) used to group the commands like commit, Rollback

DB2 can access from below environments.

  • TSO
  • CICS
  • IMS
  • BATCH

Sample create table statement

CREATE TABLE MYSUP
(
S# CHAR(5) NOT NULL PRIMARY KEY,
SNAME VARCHAR(50) NOT NULL
) IN DSRDB27.DSRC539S;

create table emp(
empno numeric(5) not null,
empname char(10));

CREATE TABLE TDPT(DPTIDY CHAR(5) NOT NULL PRIMARY KEY,
DPTNAM CHAR(15)) ;

Create Index

CREATE UNIQUE INDEX TDPTIDX ON TDPT(DPTIDY);

Sample insert Statement

insert into emp values(00001,'amudhan');
insert into emp values(00002,'girish');
insert into emp values(00003,'lenex');
insert into emp values(00004,'ramesn');
insert into emp values(00005,'arun');

Select Statements

Select query syntax:

SELECT element FROM table WHERE conditional statement.

WHERE is used with a relational statement to isolate the object element or row.

Select statement used to select records from table emp

Select * from emp where empno=00001

  • * meant retrieve all column from emp table.
  • Use select count (*) to find out total no of rows in table.
  • Use select distinct to eliminate duplicate records in table.
  • Use select max (…) to find out maximum value in a column.
  • Use select avg (…) to find out average value in a column.
  • SELECT * FROM SYSIBM.SYSTABLES WHERE CREATOR = 'owner id' - Used to retrieve the owner who creates the table.
  • SELECT COUNT(*) FROM SYSIBM.SYSTABLES WHERE CREATOR = 'owner id' – Used to know how many tables created by particular owner.

String Manipulation

  • Substring is used to retrieve specific characters in string.

       SELECT SUBSTR(FIRSTNAME,1,5) FROM EMP
       FIRSTNAME – Column name in EMP table.
       1,5 – First five characters from the column

  • Concatenate FIRSTNAME and LASTNAME using below query.

       SELECT FIRSTNAME || ‘ ‘ || LASTNAME FROM EMP;

Where Conditions

  • SELECT EMPNO FROM EMP WHERE PROJECT IS NULL;    - This used to retrieve where project is null.
  • SELECT SUM(SALARY) FROM EMP WHERE QUAL = ‘MSC’;    - This used to sum of employee salary whose is under qualification of ‘MSC’.
  • BETWEEN are used supplies a range of values.
  • IN supplies is used a List of values.
  • LIKE is used for partial string matches.
  • ‘%’ for a string of any character.
  • ‘_’ for any single characters are the two wild characters.

Group by and HAVING

   * GROUP BY partitions the selected rows on the distinct values of the column on which you GROUP by.

    * HAVING selects GROUPS which match the criteria specified.

Drop table

   Drop is used to remove the table / index from DB2 and below is sample.

       DROP TABLE MYSUP;
       drop table emp;
      COMMIT;

Commit and Rollback
    *Commit statement is used to save the result of query execution.

      Rollback statement is used to undo the updates that happen during the query execution.

Commenting in DB2
    To comment the lines in DB2 query, use first two position as --.

Common error codes in DB2

   +100 row not found
   -181 The value in column with data/time data    type does not have the correct value.
   -501 Program attempted to fetch /close a    cursor that is not open
   -803 Duplicate Row
   -805 Bind Problem
   -811 Multiple Rows
   -904 Resource not available
   -501 Trying to fetch or close a cursor    which is not opened
   -502 Trying to open a cursor which is already opened.
   -922 Authorization failure.
   -818 This is generated when the consistency tokens in the DBRM and the load module are different.

DB2 - COBOL definitions of Decimal, Smallint, Varchar, Date, Time, Timestamp.

DB2 FIELDS COBOL VARIABLES
POINT1 DECIMAL(13, 0) 10 POINT1 PIC S9(13)V USAGE COMP-3
POINT2 DECIMAL(11, 2) 10 POINT2 PIC S9(09)V99 USAGE COMP-3
CO-CDE SMALLINT 10 CO-CDE PIC S9(4) USAGE COMP
NMBR INTEGER 10 NMBR PIC S9(9) USAGE COMP
REMAR VARCHAR(240) 10. REMARK.
49 REMARKS-LEN PIC S(04) USAGE COMP.
49. REMARKS-TEXT PIC X(240).
FROM_DATE DATE 10 FROM-DATE PIC X(10).
CR_TIME TIME 10 CR-TIME PIC X(8).
TIME_STAMP TIMESTAMP 10 TIME-STAMP PIC X(26)

Simple Cobol – DB2 program


IDENTIFICATION DIVISION.
PROGRAM-ID. SELE.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
EXEC SQL INCLUDE SQLCA END-EXEC.
EXEC SQL INCLUDE PROG3 END-EXEC.
01 WS-QRY.
49 QRY-LEN PIC S9(4) COMP.
49 QURY PIC X(200).
77 T1 PIC X(5).
PROCEDURE DIVISION.
MOVE +80 TO QRY-LEN.
* MOVE 'SELECT * FROM STD WHERE SNO = ? ' TO QURY.
ACCEPT T1.
ACCEPT QURY.
EXEC SQL
PREPARE S1 FROM :WS-QRY
END-EXEC.
EXEC SQL
DECLARE C1 CURSOR FOR S1
END-EXEC.
* MOVE 'ST012' TO T1.
* ACCEPT T1.
EXEC SQL
OPEN C1 USING :T1
END-EXEC.
DISPLAY 'WORKING HERE'.
EXEC SQL
FETCH C1 INTO :SNO,:SNAME,:SADDRESS,:TOTMARKS,:SGRADE
* FETCH C1 INTO :DCLSTD
END-EXEC
EXEC SQL
CLOSE C1
END-EXEC.
DISPLAY SNO.
DISPLAY SNAME.
DISPLAY SADDRESS.
DISPLAY TOTMARKS.
DISPLAY SGRADE.
STOP RUN.

Convert DB2 – Cobol program to executable code


//DBCOB1 PROC SOURCE=SOURCE,DCLLIB=DCLLIB,GOFILE=GOFILE,
// MEMBER=MEMBER,DBRMLIB=DBRMLIB,COPYLIB=&SOURCE
//P EXEC PGM=DSNHPC,PARM=('HOST(COB2),SOURCE,APOST')
//STEPLIB DD DISP=SHR,DSN=DSN710.SDSNLOAD
//SYSIN DD DISP=SHR,DSN=&SOURCE(&MEMBER)
//SYSLIB DD DISP=SHR,DSN=&DCLLIB
// DD DISP=SHR,DSN=&COPYLIB
//SYSCIN DD DSN=&&OUTSRCE,UNIT=SYSDA,DISP=(MOD,PASS),
// SPACE=(TRK,(1,1)),DCB=(LRECL=80,BLKSIZE=3200)
//DBRMLIB DD DISP=SHR,DSN=&DBRMLIB(&MEMBER)
//SYSTERM DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD SPACE=(800,(500,500)),UNIT=SYSDA
//SYSUT2 DD SPACE=(800,(500,500)),UNIT=SYSDA
//C EXEC PGM=IGYCRCTL,COND=(5,LT),PARM='LIB,TEST,APOST'
//STEPLIB DD DISP=SHR,DSN=IGY.SIGYCOMP
//SYSLIB DD DISP=SHR,DSN=&COPYLIB
// DD DISP=SHR,DSN=&DCLLIB
//SYSIN DD DISP=(OLD,DELETE),DSN=&&OUTSRCE
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT2 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT3 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT4 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT5 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT6 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSUT7 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSLIN DD DSN=&&LOADSET,UNIT=SYSDA,DISP=(MOD,PASS),
// SPACE=(TRK,(3,3)),DCB=BLKSIZE=800
//L EXEC PGM=IEWL,PARM='LIST,MAP',COND=(5,LT)
//SYSLIN DD DSN=&&LOADSET,DISP=(OLD,DELETE)
// DD DDNAME=SYSIN
//SYSLMOD DD DSN=&GOFILE(&MEMBER),DISP=SHR
//SYSUT1 DD UNIT=SYSDA,SPACE=(CYL,(1,1))
//SYSPRINT DD SYSOUT=*
//SYSLIB DD DSN=CEE.SCEELKED,DISP=SHR
// DD DSN=DSN710.SDSNLOAD,DISP=SHR
// DD DSN=SYS1.DSN710.SDSNLINK,DISP=SHR
//B EXEC PGM=IKJEFT01,DYNAMNBR=20,COND=(5,LT)
//STEPLIB DD DISP=SHR,DSN=DSN710.SDSNLOAD
//DBRMLIB DD DISP=SHR,DSN=&DBRMLIB(&MEMBER)
//SYSTSIN DD DUMMY
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//DBCOB1 PEND

Executing DB2 – Cobol program

1.Use DSN utility to run a DB2 batch program from native TSO. (Option 6 in ISPF)
DSN SYSTEM(????)

RUN PROGRAM(XXXXXX) PLAN(XXXXXX) LIB(‘XXXX.XXX.LOADLIB’)
END

2.Use IKJEFT01 utility program to run the above DSN command in a JCL

//DSRC003S JOB MSGCLASS=A,PRTY=15,CLASS=R,NOTIFY=&SYSUID
//GO EXEC PGM=IKJEFT01,DYNAMNBR=20
//STEPLIB DD DSN='DSN710.SDSNLOAD',DISP=SHR
// DD DSN=DSRC135.DB2.LOAD,DISP=SHR
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
PROFILE PREFIX(DSRC003)
DSN SYSTEM(DSN1) RETRY(0) TEST(0)
RUN PROGRAM(SELE) PLAN(D03AP01) -
LIB('DSRC003.DB2.LOAD')
END
/*

Perl - CPAN module installation and basic perl points

How to check the Perl Version?

perl -v shows the perl version

How to check syntax in Perl?

perl -c filename.pl

How to run Perl program?

perl filename.pl

If you set the execution permission to the file then you can run

./filename.pl

What is the -e option does with Perl command?

It means single line code.

Where to get Perl modules?

You can get the Perl modules from CPAN. CPAN is Comprehensive Perl Archive Network which have large collection of Perl modules and documentations.

How to install CPAN modules?

perl -MCPAN -e 'install ModuleName'

For example to install CGI::Application,

perl -MCPAN -e 'install CGI::Application'

For windows OS, use PPM utility.

How to check the particular module is already exists or not?

perl -Mmodulename -e "print \"Module installed.\\n\";"

example : perl -MCGI::Application -e "print \"Module installed.\\n\";"

What does the first line of Perl code mean?

#! /usr/local/bin/perl

It tell the system where the perl exists.

This line is called shebang.

How to enable warning messages

Use -w which shows the warnings. It is a good practice to use -w while developing.

#! /usr/local/bin/perl -w

How to debug perl code?

use the perl -d filename.pl to enable the debug mode. get more debugging options like setting breakpoints, tracing, display etc from man perldebug .

PHP interview Questions - Part II

How to remove a element from array and how to delete whole array?

The particular array element can be removed by using unset with array index for example

$colors = array('red','green','blue');

To remove the green use unset($colors[1]);

To delete the whole array use unset with just array name unset($colors);

How to get the resource type?

using the get_resource_type() function.

How to assign value to more than one variable at the same time in PHP?

For example we have variables test,countInt and sizeInt, then we can assign same value to three variables like below

$test=$countInt=$sizeInt = 0;

How to check method exists in class?

using method_exists() function

How to use global variable inside the function?

1. Using the global keyword
2. other way to access global variable is $GLOBAL array

for example


$toysCount=10;
displaytoysCount();

function displaytoysCount() {
global $toysCount;

echo "Number of toys available $toysCount";

//otherway using GLOBAL array
echo "Number of toys available ".$GLOBAL["toysCount"];
}

What is static variable and its purpose?

Static variables are local variable, it intialize the variable only when we call this at the first time and retain it even if the program excution leaves the scope.

It helps to retain value of the variable. We can use this to keep track number of times the particular page called or something similar to that.

What does error_reporting(0) and error_reporting(-1) in PHP?

error_reporting(0) - turns off all the error reporting, no errors logged.

error_reporting(-1) - report all possible PHP errors.

When you use gettype for unintialized variable, what output will you get?

It will display NULL. for example

$output;
echo gettype($output); // NULL

Difference between print_r , var_dump and var_export?

print_r , var_dump used for debugging purpose. The var_export returns the php code. These helps to gothru the contents of the variables recursively in readable format.

print_r() - prints information in human readable format.

$mixedArray = array(12, array("lily", "rose", "pansy"));


Array(
[0] =>12,
[1] => Array(
[0] => lily,
[1] => rose,
[2] => pansy
)
)

var_dump() - it displays the structure information, it includes the type of the variable and values. For example

var_dump($mixedArray);

result like

array(2) {
[0]=>
int(12)
[1]=>
array(3) {
[0]=>
string(4) "lily"
[1]=>
string(4) "rose"
[2]=>
string(5) "pansy"
}
}

var_export() - displays parsable string represenation of the variable. It is similar to var_dump except it return valid PHP code.

var_export()

result would be

array(
0=>12,
1=>array(
0=>'lily',
1=>'rose',
2=>'pansy',
),);

In case of resource it is good use print_r than the var_dump.

What is the purpose of making register_globals off and if it is off how you will access the form variable?

It helps to improve the security of applications.

It doesn't mean this setting alone making our application secure. There are lot of practice like intializing the variable, use superglobals $_GET, $_POST etc regardless of register_global on/off to access the variables, checks for uninitialized variable etc will help.

If the register_global is set to off, then you can access the form elements using superglobal arrays $_POST, $_GET.

In PHP, how do you check particular element exists in the array or not?

in_array() function helps to achieve this.


$companies = array('apple','bell');
in_array("bell",$companies); // return true
in_array("dell",$companies); // return false

How the super class or parent class functions are called in the child class?

The parent keyword used to refer the parent class. The keyword self refers the current class. The parent class functions are called using parent::parent_functionname(); The same way the constants,static variables also accessed.

for example

class Emp{
function getEmp() {
return "select * from emp ";
}
}

class EmpDep1 extends Emp {

function getEmp() {
return parent::getEmp()." where dept_id = 1 ";
}
}

$obj = new EmpDep1();
$obj->getEmp();

Drupal Scheduling post using Scheduler Module

Using Drupal for blogging? You may be looking way to schedule the post to publish or unpublish on particular date. There is module in drupal to do this.

Scheduler module helps to schedule any node types ( blog, page, story or your own node types) post to publish or unpublish on specified date with the help of cron job.

Steps to Install the Scheduler Module:

  1. Download scheduler module from drupal website
  2. Place it in the modules directory
  3. Go to administer-> site building->modules-> enable the scheduler module
  4. Go to administer->site configuration->scheduler module settings -> field type, by default it is standard text field.

    If you want to use date popup then download Date module and JSTools module and enable it in modules. So you could use date popup for schedule the nodes.

  5. Go to administer->content management -> content types-> edit -> enable the scheduled publishing or unpublishing
  6. If you want to enable the scheduling for each type, go to each type edit and make it enable.

    Note: Make sure the cron runs.

    If you want to run this schedule module cron seperatly then add new entry to crontab. The scheduler cron is available in scheduler/cron path.

    How to use it

    Once you installed and enabled scheduled options for content type then in add/edit page there will be scheduling options.

    You can enter or select the date for publishing. If do not want to use scheduling option just leave this field blank.

COBOL Interview Questions - Part II

  1. What is file status 92?

    Logic error. example, a file is opened for input and an attempt is made to write to it.

  2. What is Static, Dynamic linking?

    In static linking, the called subroutine is link-edited into the calling program , while in dynamic linking, the subroutine & the main program will exist as separate load modules.

    You choose static/dynamic linking by choosing either the DYNAM or NODYNAM link edit option. (Even if you choose NODYNAM, a CALL identifier (as opposed to a CALL literal), will translate to a DYNAMIC call).

    A statically called subroutine will not be in its initial state the next time it is called unless you explicitly use INITIAL or you do a CANCEL. A dynamically called routine will always be in its initial state.

  3. What is AMODE(24), AMODE(31), RMODE(24) and RMODE(ANY)?
    ( applicable to only to MVS/ESA Enterprise Server).

    These are compile/link edit options.

    AMODE - Addressing mode. RMODE - Residency mode.

    AMODE(24) - 24 bit addressing.

    AMODE(31) - 31 bit addressing.

    AMODE(ANY)- Either 24 bit or 31 bit addressing depending on RMODE.

    RMODE(24) - Resides in virtual storage below 16 Meg line. Use this for 31 bit programs that call 24 bit programs. (OS/VS Cobol programs use 24 bit addresses only).

    RMODE(ANY) - Can reside above or below 16 Meg line.

  4. How can you submit a job from COBOL programs?
  5. Write JCL cards to a dataset with

    //xxxxxxx SYSOUT=(A,INTRDR)

    where 'A' is output class, and dataset should be opened for output in the program. Define a 80 byte record layout for the file.

  6. What are the steps you go through while creating a COBOL program executable?

    DB2 precompiler (if embedded sql used),
    CICS translator (if CICS pgm),
    Cobol compiler,
    Link editor.
    If DB2 program, create plan by binding the DBRMs.

  7. How do you set a return code to the JCL from a COBOL program?

    Move a value to RETURN-CODE register. RETURN-CODE should not be declared in your program.

  8. What is SSRANGE, NOSSRANGE?

    These are compiler options with respect to subscript out of range checking.

    NOSSRANGE is the default and if chosen, no run time error will be flagged if your index or subscript goes out of the permissible range.

  9. What is file status 39?

    Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL program & the JCL (or the dataset label). You will get file status 39 on an OPEN.

  10. Is it possible to REWRITE a record in an ESDS file? Is it possible to DELETE a record from it?

    Can rewrite(record length must be same), but not delete.

  11. What is the mode in which you will OPEN a file for writing?

    OUTPUT, EXTEND

  12. How do you reference the various file formats from COBOL programs?

    Fixed Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0

    Fixed Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, do not use BLOCK CONTAINS

    Variable Block File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, BLOCK CONTAINS 0. Do not code the 4 bytes for record length in FD that is JCL record length will be max record length in program + 4

    Variable Unblocked - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS V, do not use BLOCK CONTAINS. Do not code 4 bytes for record length in FD that is JCL record length will be max record length in program + 4.

    ESDS VSAM file - Use ORGANISATION IS SEQUENTIAL.

    KSDS VSAM file - Use ORGANISATION IS INDEXED, RECORD KEY IS, ALTERNATE RECORD KEY IS

    RRDS File - Use ORGANISATION IS RELATIVE, RELATIVE KEY IS
    Printer File - Use ORGANISATION IS SEQUENTIAL. Use RECORDING MODE IS F, BLOCK CONTAINS 0. (Use RECFM=FBA in JCL DCB).

  13. What is COMP SYNC?

    Causes the item to be aligned on natural boundaries. Can be SYNCHRONIZED LEFT or RIGHT.

    For binary data items, the address resolution is faster if they are located at word boundaries in the memory. For example, on mainframe the memory word size is 4 bytes. This means that each word will start from an address divisible by 4. If my first variable is x(3) and next one is s9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3 ( assuming that it starts from 0 ). If you specify SYNC, then the binary data item will start from address 4. You might see some wastage of memory, but the access to this computational field is faster.

  14. What is the maximum value that can be stored in S9(8) COMP?

    99999999

  15. What is file status 39?

    Mismatch in LRECL or BLOCKSIZE or RECFM between your COBOL program & the JCL (or the dataset label). You will get file status 39 on an OPEN.

  16. What compiler option would you use for dynamic linking?

    DYNAM.

Linux / Unix find command with various options

find . -name state* to search the current ditectory for the file name start with state

find /tmp -name *state* to search the /tmp directory to find the file name contains state

  1. How to apply command on each file found in the find command?

    find command with exec flag helps to apply command on each file found. For example search for file with extension tmpl and mv those files to template directory.

    find . -name '*.tmpl' -exec mv {} template \;

    Here {} is place holder for each file found.

    \; means end of the command.

    There is other flag -ok works same way as exec except, it will prompt for user confirmation before execute the command.

    find /tmp -name '*.txt' -ok rm {} \;

  2. How to redirect the output of the find command to file?

    > used to redirect the output to file.

    find / -name '*.out' > outputfiles.txt find the out files from root directory and place it in outputfiles.txt.

  3. How to find files based on size?

    find command with -size flag used to find files based on size.

    find . -size+1000k to find the files which size is >1 MB in the current directory.

  4. How to find the files based on access time?

    find /tmp -atime -2

    To find files in /tmp directory which accessed less than 2 days or few days before that.

    To find files in /tmp directory which is accessed last 20 mins

    find /tmp -amin -20

  5. How to find the files based on the last modified time?


    To find the files which modified 1 day or fewer days ago.

    find . -mtime -1

  6. How to find the regular file using find command?

    The type flags used to search the regular files.

    find . -type f

    Find the files which have write access to group?

    find . -perm -g=w

    It will find the files in the current directory and have write permission to the group.

  7. How to find out the empty files and remove it using find command?

    find . -empty -exec rm {} \;

    The -empty flag finds the empty files in the current directory and execute rm command on each files found.

  8. How to find files ownned by particular user?

    find . -user sasikala

    To find the files owned by sasikala in the current directory.

The find command have lots of other options. We can combine two or more conditions with and/or option in command. It have amazing options to find files in critical times.

Example for get and set the value to form element using JQuery

The jQuery .val() function used to set and get the value of the form elements.

For example:

<html>
<head>
<title>get the element value
</title>
<script type="text/javascipt" src="jQuery.js"></script>

<script>

 function toGetVal() {
    var empName = jQuery('#empname').val();
    alert(empName);
 }

 function toSetVal(){
    var deptName = "COMM";
    jQuery(#deptname").val(deptName);
 }
</script>
</head>

<body>
<form name="testform" id="testform">
<input id="empname" name="empname" value="testname">
<input id="deptname" name="deptname" value="">
<input id="setVal" name="setVal" value="To Set Value" type="button" onclick="toSetVal()">
<input id="getVal" name="getVal" value="To Get Value" type="button" onclick="toGetVal()">
</form>
</body>
</html>

Other Points

How to check the element exists in the form?

jQuery('#empname').val() will return undefined if the element not exists. So you could check like this

 if(jQuery('#empname').val()!=undefined){
    alert('the element exists in the form');
 }

How to unset the value to form element?

 jQuery('#deptname').val('');

Debugging or Troubleshooting the Perl DBIx::Class

Working in DBIx::Class, constructing more complex query. Something went wrong, not getting the expected result?.

Want to debug? There are two way's to print the query in the log.

$schema->storage->debug(1);
    or
export DBIC_TRACE=1


You can use either way but it should be before doing $schema->resultset(....

Simple example:

$schema->resultset('Customer');

It will print the "select * from Customer" into the log file.

It will really helpful in case of the complex queries with muliple join, alias.

If you want to write this output to other file then use debugfh.

For example:

$schema->storage->debugfh(IO::File->new('/tmp/dbixquery.log', 'w');

It writes the debug output into /tmp/dbixquery.log.

Oracle rownum and Order by

Oracle rownum used to get the range of records, it is like MySQL limit.

MySQL:
select * from customer limit 5;

Oracle:
select * from customer rownum <=5;

For example: We have Customer table like below.

Table : Customer
customer_id
customer_name
customer_address
customer_city
customer_pincode
customer_state
customer_country

To fetch the customers in the ascending order of customer_name.

select * from customer order by customer_name;

Now we want to fetch the first 5 records of the customer based on ascending order of the name.

select * from customer where rownum<=5 order by customer_name;

Got the result as expected? no. Why?

When we use rownum with order by clause the result won't be as expected. Since the Oracle apply the rownum before the order by clause.

To get the result as expected, use dummy query like

select * from (select * from customer order by customer_name) a where rownum<=5;

this works only if we fetch first records onwards. This is not working with between or rownum with >.

So what's the solution, how to get the records which have rownum and order by?

Here is the workaround or way to get it. Use two dummy queries around the main query to get this done.

select * from
   (
    select a.*, rownum r from
     (
      select * from customer order by customer_name
     ) a
     where r>10 and r<=20
   );

Did n't find any performance issue on using the two dummy queries around the original.

This could be done in MySQL using limit as simple as below

select * from customer order by customer_name limit 10,20;

The Oracle rownum or limit are mainly used for paginating the query results. Working in pagination with sorting options and using Oracle Database, the above oracle query will help you.

Linux / Unix Window Split in Vim

In Vim , a window is a viewport onto a buffer. Buffer is the memory space where the file loaded for editing.

You can split the window in vim following ways.

Way 1: Using :split

vim filename1.pm

:split filename2.pm

Way 2: Using -o or -O options

To split vertically
vim -O file1 file2

To split horizontally

vim -o file1 file2

Way 3: Using :vsp

vim file1.txt
:vsp file2.txt

which split the window veritically and open file2.txt.

:vsp also used to split with in the file to view in other window.

How to perform commands in both windows?

For example you want to set line numbers for both windows.

:windo set number

use :windo to execute the command in all the windows.

How to move between buffers?

When you are in particular buffer, you want to change it to other buffer, you could use

:bn - to go to next buffer

:bp -to go to previous buffer

To get the list of open buffers and its id number use :ls in vim.

You can also use this number to switch between tabs like below

:b 1
:b 2

How to resize the window?

:resize -N - decrease the height
resize +N - increase the height

:vertical resize -N - decrease width
:vertical resize +N - increase width

How to move or switch between windows?

CTRL+W and CTRL+W (2 times)- to move between all open windows.

How to close the window or all windows?

Normally we use :wq to save and quit, :q! to quit with out saving and just write and continue :w. The close the single window the above commands can be used.

To close all the files :qall

To save saves of all files :wall

To save & quit :wqall

To quit with out save changes :qall!

Perl hash and hash reference examples

Hash is data structure like array whereas array have indices , hash has unique key strings. In hash each keys associated with values. In Perl % used to define the hash variable.

For example:

my %fruitsColor= ('Watermelon'=>'Green' ,'Apple'=>'Red','Orange'=>'Orange');

 

Sort using multiple column

How to use sort for multiple column?

Protect Microsoft Excel Spreadsheet

Protect Microsoft Excel Spreadsheet using password

Sometimes you may have sensitive data in excel spreadsheet and want to proctect it, here is the way

In Excel 2007

Press Alt key and F key sametime(ALT+F), select the prepare -> encrypt dococument -> enter the password -> re enter the password

In Excel 2003

select tools -> options-> select security -> enter password for open -> modify(if required)

next time onwards, if you open a excel file which you protected, it will ask for password before showing the content of the sheets.

Caret Browsing - Internet Explorer and Mozilla

What is Caret browsing?

Pressing F7 in mozilla or IE 8 onwards will provide option to toggle caret browsing option.

Instead of using mouse to select the text, in this caret browsing you can select text using home, page up, page down, end keys.

How to enable / disable the caret browsing option in IE and Mozilla?

In IE, Internet Options -> Advance tab ->check / uncheck the Enable Caret Browsing for new windows and tabs.

In Mozilla, type about:config -> look for line accessibility.browsewithcaret_shortcut.enabled, make it true or false.

What is Bluejacking, bluebugging?

Sending anonymous messages to bluetooth enabled devices is called bluejacking.

When we enable the bluetooth in our devices like mobile, laptops... it can be identified by other bluetooth enabled devices in and around 32 feet. They could send the anonymous message or virus files to your device.

Bluetooth enabled devices will ask permission on receiving the files from other devices like whether to accept or deny? It is always good practice not to accept the files from unknown devices.

Due to lack of awareness, accepting the devices and get attacked is called bluebugging.

Popular Top 5 free Antivirus softwares

Uses of the internet is increased lot and it going to be more in future. We use PC or laptop or mobile to surf daily. So we should have at least some basic protection from virus,spyware, worms and hackers and etc.

Most of us technical or non technical, we don't want to spend much for antivirus softwares. It is recommended to use the antivirus software. There are lot of free antivirus softwares available, which gives basic protection.

Top 5 popular Antivirus softwares

  • AVG
  • AVG have Internet Security Business Edition, Home Edition and Free Edition. The Free edition provides basic protection and have antivirus and anti-spyware. It helps to surf safely,block scammers and spammers. It identifies the malicious website before visit them.

    We could do online shoping or banking with confidence. It supports Windows 7, Vista ,xp and 2000. This is the most frequently downloaded antivirus software.

  • Avast Free Antivirus
  • It also supports Windows 2000/XP/Vista/7 and minimum hardware requirement is 128 MB RAM, 300 MB free hard disk space and pentium 3 processor.

    It provides basic protection againsts the virus, spyware, trojans and other malicious agents like other antivirus softwares.

    Avast have Free Antivirus, Pro Antivirus and internet security editions. Avast different from other AntiVirus, why? Avast different from other antivirus, since it have hi-tech features like

    * Boot time scanning
    * Intelligent scanning - scans only changed files.
    * Multithreaded scanning
    * Wake-up/Scheduled scanning
    * fast application updates, green computing

  • Avira Antivirus:
  • The free package has basic protection againts worms,virus, trojans. Easy to install and it is fast in scanning. If the file is infected, hope it is easy to remove the virus and repair the file.

    The other two popular free antivirus softwares are

  • Ad-Aware Free Internet Security
  • PC Tools AntiVirus Free

Install the best suited antivirus software and protect your system.

Just Friends VS. Best Friends

A Just Friend says..hi,..hello,..bye,...and walks away...
A Best friend always stop by your side & asks how r u doing ??

A Just Friend has never seen you cry.
A Best friend has shoulders soggy from your tears.

A Just Friend thinks the friendship is over, when you have an argument.
A Best friend knows that it's not a friendship, until after you've had a fight.

A Just Friend hates it when you call, after he has gone to bed.
A Best friend asks you.... why you took so long to call.

A Just Friend, when visiting, acts like a guest.
A Best friend opens your refrigerator and helps himself.

A Just Friend jealous about your romantic history.
A Best friend wonders of your love story.....

A Just Friend expects you to be always there for any help.
A Best friend is always there, wherever you require any help.

A Just Friend doesn't have time in his/her busy schedule,
A Best friend always have time for you in his/her busy schedules....

A Just Friend phones you whenever he/she has some work,
A Best friend calls you often just to hear your voice.....

A Just Friend doesnt have anything to talk to you on phone,
A Best friend doesnt know...what all to finish...

Health - Very Very Important Tips

Answer the phone by LEFT ear.

Do not drink coffee TWICE a day.

Do not take pills with COOL water.

Do not have HUGE meals after 5pm.

Reduce the amount of OILY food you consume.

Drink more WATER in the morning, less at night.

Keep your distance from hand phone CHARGERS.

Do not use headphones/earphone for LONG period of time.

Best sleeping time is from 10pm at night to 6am in the morning.

Do not lie down immediately after taking medicine before sleeping.

When battery is down to the LAST grid/bar, do not answer the phone as the radiation is 1000 times.

Send this link to those whom you CARE about!