01st Sep 2009

How To Create Mirror Partition In Linux System

This article shows how to configure raid 1 mirroring into your linux server

you must have two hard drive installed on your linux server with the same capacity

You can listed them using the following command

fdisk –l

This will display your currently installed hard drive on your linux server

/dev/hda/

/dev/hdb/

Then you have to create a logical partition on both hard drives with same capacity

Following command willl create a new partition on your linux server , for first hard drive (/dev/hda)

fdisk /dev/hda

This will ask for primary or extended partition

Type e for extended partition

Next will ask for cylinder size of your partition , don’t change anything

Next will ask for actual space for your extended partition

Type +10000M

Type w for write partition table

Now you have to create a logical partition using the following command

fdisk /dev/hda

N for new partition

L for logical partition

Just enter with the default configuration (cylinder size)

Type the size of your logical partition +5000m

Type w for write partition table

Remember by default when you create a new partition linux uses partition id number 82 .

You have to change this partition id fd for raid configuration with the following command

fdisk /dev/hda

Type l for change partition id

This will ask you which partition id would you like to change type your partition number

For example 5

Type fd for raid partition id

Type w for write partition table

You have to complete the same procces on second hard drive

Now you can start your raid 1 configuration using the following command

But before do this please check mdadm rpm package is installed or not

You can check this using rpm –q mdadm

You can also install this package using the following command

Type rpm –ivh mdadm

Now run the following command to create raid array

Type mdadm –create /dev/md0 –level=1 /dev/hda5 /dev/hdb5

This will create a raid partition on your linux server

You can see the details using the following command

Type mdadm –detail /dev/md0

Now you have to format this partition to use them

Type mkfs –t ext3 /dev/md0

This will write ext3 file system on your raid partition

Then you have to mount this raid partition on some directory using

Type mount /dev/md0 /raid1

If one of the hard drive faild on raid 1 type the following command to remove them from raid1

Type mdadm /dev/md0 –f /dev/hda5 (to fail your harddrive in raid1 )

Type mdadm /dev/md0 –r /dev/hda5 ( to remove your hard drive from raid1 )

Now you can join a new hard drive create logical partition with same capacity & join into you raid1 partition using the following command

Type mdadm /dev/md0 –a /dev/hdc5


You can see raid1 will syncs the data with the new hard drive using

Type mdadm –detail /dev/md0

Posted by Posted by bhumish.shah under Filed under Uncategorized Comments No Comments »

01st Sep 2009

Moving /opt/ Data To New Partition In Linux Due To Low Disk Space

1. Introduction (Moving /opt data to a new partition)

The partition /opt is one of the most-often-moved partitions Because Linux Installs Third Party Software in /opt Directory. For Example Zimbra, Scalix.. So there is Disk Space Issue Occurs after Log Period

Some Times All Space On /opt Becomes Full and Your Application’s Performance Becomes Poor. In That Case you need an additional Harddrive or a Partition That Contains Big Space to Moved

In This Article I Will Show You How to Transfer Your /Opt Data to New Harddisk or Another Partition

Add New Hard Disk onto Your Server

When You Attach New Hard Drive on Server, It Will recognized as /dev/sdb.
Your First Hard Drive should be /dev/sda

2. Create new partition on your new hard drive with fdisk command:

fdisk /dev/sdb

Press n for Create a New Partition

This Will Ask For Primary or Extended Partition

Press p for Primary Partition

Press Enter for Default Setting in cylinder Size of Partition

Type the Size of the Partition That You Want To Allocate To Your New Partition

For Example: +80000M

This Will Create 80 GB New Primary Partition in to Your New Hard Drive

Press w for Save the Settings

Type partprobe Command to update The Kernel about newly added Partition

Now Format the Partition Using ext3 File System So That We Can Use Partition

mkfs –t ext3 /dev/sdb1

You Can Check Newly Created Partition Status Using fdisk –l Command . This Command Will Give You the Status of All the Partition

3. Mount the new file system in /mnt

Create a directory called /mnt/newopt, and then mount the new partition there:

# mount /dev/sdb1 /mnt/newopt

4. Drop to single-user mode

You must go To Single User Mode to Copy All Data in /opt to /mnt/newopt. You shouldn’t have any files open in /home, and entering single-user mode eliminates this possibility:

#Init 1

5. Change directories to /home and copy files

Type The Following

# cd /opt
# cp -avx * /mnt/newopt

The cp -avx command recursively copies the contents of /home to /mnt/newpopt, preserving all file attributes.
After this command finishes, /mnt/newopt will contain an exact copy of all the files and directories currently in /opt.

6a. If you installed /opt on separate partition then follow below steps

Unmount the old partition by typing:

# cd /
# Umount /opt/

Then, unmount and remount the new partition:

# umount /mnt/newopt
# mount /dev/sdb1 /opt

Now, the new partition is available at /opt and is ready to be used. We can perform the last few steps in multiuser mode. Exit single-user mode, so that the system is back up and running Type: init 5

Add This Entry To /etc/fstab File

/dev/sdb1   /opt   ext2   defaults   1   2

6b. If you installed /opt on shared partition then follow below steps

These instructions are for systems where the old /opt is on a shared partition.

# cd /
# mv /opt /opt.old
# mkdir /opt
# mount /dev/sdb1 /opt

Add This Entry to /etc/fstab File

/dev/sdb1   /opt   ext2   defaults   1   2

That way, your new partition will get mounted correctly the next time the system is rebooted.

We left the old /opt directory/partition behind, just in case there were problems copying files. After verifying that the system is running smoothly, you can remove the /opt.old directory.

Posted by Posted by bhumish.shah under Filed under linux Comments No Comments »

01st Sep 2009

CSS Support Guide for HTML Emails

The sole intent of my article is to demonstrate how one can use standards-based markup for HTML emails. Like it or not, HTML emails are here to stay. So, For those of you who are ready to improve the markup of your HTML emails, here is a quick compatability guide to HTML tags & CSS Properties for different web-based & PC based email environments.

HTML Tags PC based email environments Web-based email environments
  Outlook 2003/OE Gmail Yahoo Mail Windows Live Mail Hotmail
<style> element in the <head> yes no yes yes no
<style> element in the <body> yes no yes yes yes
<link> element in the <head> yes no no no no
<link> element in the <body> yes no no no no
           
CSS Properties          
background-color yes yes yes yes yes
background-image yes no yes no yes
background-position yes no no no no
background-repeat yes no yes no yes
border yes yes yes yes yes
border-collapse yes yes yes yes yes
border-spacing no yes yes no no
bottom yes no yes no yes
color yes yes yes yes yes
cursor yes no yes yes yes
display yes no yes yes yes
float yes no yes yes yes
font-family yes no yes yes yes
font-size yes yes yes yes yes
font-style yes yes yes yes yes
font-weight yes yes yes yes yes
height yes no yes yes yes
left yes no yes no yes
letter-spacing yes yes yes yes yes
line-height yes yes yes yes yes
list-style-image yes no yes no yes
list-style-position yes yes no yes no
list-style-type yes yes yes yes no
margin yes yes yes no no
opacity no no yes yes no
overflow yes yes yes yes yes
padding yes yes yes yes yes
position yes no no no no
right yes no yes no yes
text-align yes yes yes yes yes
text-decoration yes yes yes yes yes
text-indent yes yes yes yes yes
text-transform yes yes yes yes yes
top yes no yes no yes
vertical-align yes yes yes yes yes
visibility yes no yes yes yes
width yes yes yes yes yes
word-spacing yes yes yes yes yes
z-index yes no yes no yes

Concluding Words..

HTML emails that contain semantic markup and CSS gel very well with the most commonly used email clients. And for clients that offer poor or no support, the semantic markup allows for graceful degradation.
And, for all those who really do not want to handle the long list mentioned above, you always have these words to mention above your email “Having trouble reading this email? Click here to View it in your browser.” ;)

Posted by Posted by Supriya Agnihotri Jagani under Filed under design Comments 4 Comments »

26th Aug 2009

Introduction to Palm Pre Development

Palm Pre

Palm Pre

Palm Pre is mobile technology and it mainly includes the following functionality

  • Move and open multiple applications very easily.
  • Palm Services like Backup and restore important data and erase data remotely if phone is stolen or misplace.
  • Palm web OS™ platform are integrated with other apps on the phone

What is webOS?
Palm webOS is an embedded operating system developed by Palm, Inc. for a range of devices. It includes many features like designing, coding and debugging.

What is Mojo?
Mojo is “an application framework based on the HTML5, CSS, and JavaScript standards”.  Applications built with Mojo “are installed and run directly on the device at native speeds and have access to a wide range of device services”.

While Mojo should be sufficient for developing a wide range of applications, other graphics-intensive programs such as games would probably require a lower-level webOS API.  There has been some speculation that Palm will release a second API that enables developers to access the hardware more directly for these types of applications.

Scene:
Scenes are mutually exclusive views of the application within a stage. Most applications provide different kinds of scenes within the same stage, while simple applications (such as Calculator) only have a single scene. Typically, a new scene is pushed after a user action, such as a tap on a UI widget, and the old scene can return with a “back” gesture. Scenes are managed by a scene stack, with new scenes pushed onto and off of the stack with the last scene visible.

Scene assistant:
A scene assistant is a “controller” for a scene.  It contains the logic behind how the scene behaves and responds to user input.

Widgets:
Widgets support webOS user interface, and Mojo definies styles for each of the widgets. The styles are available simply by declaring and using the widgets, or they can be overridden either collectively or individually with custom CSS.

The List widget is the most important in the framework, as “the webOS user experience was designed around a fast and powerful list widget, binding lists to dynamic data sources with instant filtering and embedding objects within other widgets and lists.”

Simple widgets include buttons, checkboxes, sliders, indicators, and containers.

The Text Field widget includes text entry and editing functions, including selection, cut/copy/paste, and text filtering, and can be used in conjunction with a list widget.

Menu widgets can be used with specified areas of the screen, including the view and command menus that are completely under your control. The app menu is handled by the system, but custom items can be added to the menu, as well as functions to service the help and preferences items.

Picker and viewer widgets are more complex, with pickers used for browsing and filtering files or contacts, or for selecting addresses, dates or times. Viewers are used to play or view items such as audio, pictures, video or web content within your application.

Requirement for development in Palm Pre

How to start development in Palm Pre?
Before starting development in Palm Pre you need  to download VirtualBox, Mojo SDK and Eclipse 3.4.2 version. Install VirtualBox first, then only download and install Mojo SDK. It is pre-requisite for Mojo SDK installation. When you start installing Mojo SDK, make sure that VirtualBox is not running.

Now Double-click the Palm SDK Installer file.

  • The Palm emulator becomes available in the Applications folder.
  • The Palm command-line tools become available from the Terminal.
  • Create or choose a directory to use as your application development workspace.

You can start the Palm Emulator by double clicking on its icon in the Application directory. At that time Virtual box starts up and creates virtual machine that hosts the Palm Web OS Platform. When you start VirtualBox first time there are several message will come. Just click ok on that diaglog box and continue.

In Eclipse you need to add Mojo SDK plug-ins. For that,

  • Start Eclipse.
  • go to Help Menu, Select Software Updates and click on Available Software tab.
  • click and select Add Site button. and in the location field http://cdn.downloads.palm.com/sdkdownloads/1.1/eclipse-plugin/eclipse-3.4/site.xml and click Ok.
  • check Palm Mojo SDK and click Install.
  • Restart Eclipse.

After installing Mojo SDK add plugins in the Eclipse,

Selecting the webOS Perspective

1.  Select Window > Open Perspective… > Other…

2.  Select webOS from the Open Perspective dialog.

3.  Click OK.

Preparing  webOS Application

From the New Project menu:

1.  Start Eclipse.

2.  Select File > New Mojo Application.

3.  On the next screen, type a name in the Project Name field.

4.  Enter your application info:

    • Title
    • Vendor
    • ID
    • Version

5.  Click Finish.

From the New App toolbar menu:

1.  In the Eclipse toolbar, click the Mojo Wizard icon and select New App from the drop down menu.

2.  On the New Project Wizard screen, type a name in the Project Name field.

3.  Enter your application info:

    • Title
    • Vendor
    • ID
    • Version

4.  Click Finish.

Adding a scene to your webOS Application,

From the New Project Menu:

1.  Select File > New > Mojo Scene.

2.  On the New Mojo Scene Screen, make sure the correct project is selected.

3.  Enter a name for your scene and click Finish.

From the New Scene toolbar menu:

1.  In the eclipse toolbar, click the Mojo Wizard icon and select New Scene from the drop down menu.

2.  On the New Mojo Scene Screen, make sure the correct project is selected.

3.  Enter a name for your scene and click Finish.

Running a webOS Application

1.  Select Run > Run Configurations…

2.  Select Palm Application and click the New Configuration icon to create a new launch configuration.

3.  Change the name.

4.  Select your project from the drop-down list.

5.  Select the Target:

    • Palm Emulator if you are using the emulator.
    • Palm Device if you are using a device (make sure your device is in Developer Mode).

6.  Click Run to install and run the application.

Installation starting problem when you run emulator first time.

If you are running on installing the application for the first time in Palm Emulator there is a possibility of getting following error.

Error Message

Error Message

To fix it you simply need to enter the following two commands in your terminal command prompt:

$ sudo chmod 644 /Library/LaunchDaemons/com.palm.novacomd

$ sudo /opt/nova/bin/post-install.sh

For more information please go through following site, you will find out more regarding this error.

http://www.ozmox.com/2009/07/25/webos-on-mac-os-x/


Tutorial of your First Palm Pre Application development:

Now how to develop first Palm Pre Application, following steps will guide you in details of Palm Pre development.

For that from New Project menu:

1. Start Eclipse.

2.  Select File > New Mojo Application.

Give the name of the application.

What is a Stage?

Now in the application you need to set the stage. A stage is the platform on which you build the user interface for your application. A stage generally corresponds to a single card, or application window. Most simple applications have a single stage, contained in the file index.html. An application that lets the user perform more than one action concurrently might require more than one stage. For example, an email application might show the inbox on one stage, but launch a second stage to compose a new email message. Notification and background applications have no stages at all.

So change in the Index.html page.

<?xml version=”1.0″ encoding=”UTF-8″?>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”

“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en“>

<head>

<title>PalmTest</title>

<script src=”/usr/palm/frameworks/mojo/mojo.js” type=”text/javascript” x-mojo-version=”1″ />

<script src=”app/assistants/stage-assistant.js” type=”text/javascript“></script>

<script src=”app/assistants/first-assistant.js” type=”text/javascript“></script>

<!– application stylesheet should come in after the one loaded by the framework –>

<link href=”stylesheets/main.css” media=”screen” rel=”stylesheet” type=”text/css” />

</head>

<body>

<h2> Testing Application

</h2>

<p>

One stage application

</p>

</body>

</html>

Now create new scene named “First-scene”. It will add two files and one json file.

The palm-generate command creates the view and the assistant for the first scene. It also adds a few lines to sources.json to correlate the assistants and scenes. Take a look at the following files:

  • /app/views/first/first-scene.html — This is the view.
  • /app/assistants/first-assistant.js — This is the assistant.
  • sources.json — This file now includes JSON information that binds first-assistant.js to the first scene.

Now modify the first scene html file for adding new controls.

Open first-scene.html and replace the content with the following

<div>

<div class=”palm-header”>Header</div>

<div id=”count”>0</div>

<div id=”MyButton” x-mojo-element=”Button”></div>

</div>

Now to show the scene, you have to tell stage to push the scene.

To push the application scene

1.  Open stage-assistant.js.

2.  Edit the StageAssistant function to contain the following:

function StageAssistant () {

}

StageAssistant.prototype.setup = function() {

this.controller.pushScene(”first”);

}

Now how to bind and register the handler, there are two steps.

  • binding the handler to the scene assistant’s scope, using bind(this)
  • registering the handler as a listener, using Mojo.Event.listen()

Now open first-assistant.js and edit setup function and add following code into that.

FirstAssistant.prototype.setup = function() {

// set the initial total and display it

this.total = 0;

this.controller.get(”count”).update(this.total);

// a local object for button attributes

this.buttonAttributes = {};

// a local object for button model

this.buttonModel = {

“buttonLabel” : “CLICK HERE”,

“buttonClass” : “”,

“disabled” : false

};

// set up the button

this.controller.setupWidget(”MyButton”, this.buttonAttributes, this.buttonModel);

// bind the button to its handler

Mojo.Event.listen(this.controller.get(”MyButton”), Mojo.Event.tap, this.handleButtonPress.bind(this));

}

After creating build, run the application. It will shows the count that how many times you pressed “Click Here” button. It will increase every time you press click button.

PalmPre Sample

PalmPre Sample

Same way you can add more than one scene and navigate from one scene to other scene using following script which will help you to redirect to second scene by pushing the scene.

FirstAssistant.prototype.nextScene = function(event){

if (this.textModel.value == “Testuser”)

{

Mojo.Controller.stageController.pushScene(”second”,this.textModel.value,this.Passowrdmodel.value);

}

else

{

this.labelmodel.value=”Invalid User and Password”;

}

}

And you have your first Palm Pre application ready! I hope you enjoy Palm Pre development and leverage the first mover advantage of the platform.

Following are some good references for Palm Pre development:

http://developer.palm.com/

http://www.weboshelp.net/webos-mojo-development-resources

Posted by Posted by Brijesh Patel under Filed under Code Comments No Comments »

19th Aug 2009

How to call procedure from another procedure or Use the data of dynamic sqlserver query in procedure

Today I will explain very small but very useful feature which I have used in the past for the procedures. When I was new to SQL Server I was facing many problems and this was one of them.

We all know user defined functions has limitations that we can not use #temp table or table variables in UDF. Because of that we can not get the data from another function in the UDF.

So to overcome this problem, we can create the procedure in which we get data from another procedure for further manipulation. Question is how to get data from another procedure? You will get the answer of this question in this post.

e.g., suppose procedure ReturnStudentDetail returns the table with two fields “Name” and “City” so how can you get that table in another procedure for further manipulation.

– Create Table

Create table #StudentDetail

(Name varchar (50), City varchar (100))

– Below code will give you data in the procedure

Insert into #StudentDetail

Exec ReturnStudentDetail

This syntax works only if we use create table. You can also use dynamic sqlserver query output for inserting data in #temp table.

– Create Table

Create table #StudentDetail

(Name varchar (50), City varchar (100))

Declare @sql as varchar (500)

Set @sql = ‘Select Name, City from tbl_StudentDetail where ……..’

– Below code will give you data in table

Insert into #StudentDetail

Exec (@sql)

So, this is how you can get the data from another procedure or Dynamic sqlserver query output in Table. Basic thing is whatever the structure of data being returned, you have to create table on basis of that and use that table to get data from procedure or dynamic sqlserver query.

I hope this feature is useful for you in future. Let me know if you find any better way to achieve this.

Posted by Posted by kuldip.bhatt under Filed under SQL Server Comments No Comments »

13th Aug 2009

Run SWF file in Salesforce Environment

For all the developers who are just starting development in Salesforce may find this article useful. I am going to tell you how you can run an SWF file in Salesforce.

First of all add a reference to the Salesforce namespace to  mx:Application tag and create a connection to the Salesforce.com server.

Eg.

<mx:Application xmls:mx=”http://www.adobe.com/2006/mxml”    xmls:salesforce=”com.salesforce.*” layout = “absolute”/>

<salesforce:Connection id=”apex”/>

The Connection object is already created, so to activate it,Prepare a LoginRequest object by populating the username and password fields. We have to define Callback function(loginResult) that will be fired off when the login response from the Salesforce.com server is received.

Eg.

private function login():void

{

var lr:LoginRequest = new LoginRequest;

lr.username = username.txt;

lr.password = password.txt;

//  lr.server_url = Application.application.parameters.server_url;

// lr.session_id = Application.application.parameters.session_id;

lr.callback = new AsyncResponder(loginResult);

apex.login(lr);

}

No need to give lr.session_id and lr.server_url when running application on local machine.

Deployment

We have three choices to deploy our application.

  1. Deploy it to own server.

  2. Deploy it on Salesforce Environment as an S-Control.

  3. Compile application as an Adobe AIR application and use the new runtime to use the application on the desktop without an application or Web-Server.

Deploy application on Salesforce Environment as an S-Control

To embed the Flex application as an S-Control , compile application for use in Salesforce by modifying the LoginRequest object in code to use the lr.server_url and lr.session_id arguments instead of lr.username and lr.password.

Now log in to Developer account of Salesforce.com and perform following steps.

  1. Click on Setup.

  2. Expand the Develop menu and create S-Control.

  3. Create a new one and give it memorable label and name.

  4. The type will be HTML

  5. In the filename field, browse and select the swf file.

  6. In the content area wirte the following code.

<embed src=”{!Scontrol.JavaArchive}” play=”true”   bgcolor=”#f3f3ec”  width=”100%” height=”100%” name=”FlexSalesforce”  Align=”middle”  flashvars=”session_id={!API.Session_ID}& server_url=    {!API.Partner_Server_URL_90}” loop=”false”allowScriptAccess=”always” type=”application/x-shockwave-flash”  pluginspage=”http://www.adobe.com/go/getflashplayer”</embed>

Here there are three Salesforce.com variables.

  1. Scontrol JavaArchive.

  2. API.Session_ID.

  3. API.Partner_Server_URL_90.

The last two are passed into the SWF when it loads in the browser. These maintain session state. So no need to login while running SWF file.

Now create Tab to house S-Control just created. Create a New Web-Tab with type of Custom S-Control. In step three , Select the S-Control just created to be the content on that tab. Click next through steps four and five. A new tab appear on the top of the screen.

Click on the tab. SWF file will run without required login details.

I hope you found this article useful. Let me know if there are any better ways to do the same thing.

Posted by Posted by nishant.shah under Filed under Flex, salesforce Comments No Comments »

13th Aug 2009

How to perform stress testing in QTP

1. Record the script which you want to perform for stress testing.

For Example:  if you want to add 1000 records then just record add functionality  script.

2. Now just add a loop for that script which contains add record functionality. See below example

For i=0 to 1000

Put your add record script code here. It will repeat the add record loop till 1000 entries will be done.You can insert  1000 records using For.. Next loop.You can also insert more than 1000 or more.Just change your for loop condition for that.

Next will increase your loop counter

Next

Below code is a full example of the stress testing:

For i=0 to 1000

Below code will insert first name jigar. For unique name you can pass value of  i so it will insert unique name each time.

Browser(”PMS”).Page(”PMS_3″).WebEdit(”txt_Name”).Set “Jigar” & i

Below code will enter address in the address field.

Browser(”PMS”).Page(”PMS_3″).WebEdit(”txt_Address”).Set “Surat”

Below code will enter mobile number  in the mobile number field.

Browser(”PMS”).Page(”PMS_3″).WebEdit(”txt_No”).Set “9992426690″

Below is code to save the details

Browser(”PMS”).Page(”PMS_3″).Link(”btn_save”).Click

Next

This is a script to add 1000 records.

Posted by Posted by mehul.brahmbhatt under Filed under Uncategorized Comments No Comments »

24th Jul 2009

How to get delimiter separated values in the tabular format in SQL

When ever we write script or code in SQL Server we all face problem like following.

“We store the value in database with the delimiter. Now we want to use that value in the another Procedures or Views and may be to display in reports or any where else in the system. At that time we face problem in getting data out of those delimiter”

So lets see how to get the data in the table format from one column value in which values are stored with some delimiter.

Below is the table value function which gives desired output in the table format.

Parameters which need to be passed in function are:

@String = string value which needs to be formatted for e.g. string like ‘IT,Marketing,Production’. Here as we can see values are separated by comma “,”.

@Delimiter =  Delimiter like coma(,) , Pipe(|)  etc.

Function Code
==========

Create FUNCTION dbo.Split_String(@String nvarchar(4000), @Delimiter char(1))
RETURNS @Results TABLE (Items nvarchar(4000))
AS
BEGIN

DECLARE @No INT
DECLARE @Item nvarchar(4000)

– Initilize the @no variable with 1
SELECT @No = 1

– if null then return
IF @String IS NULL RETURN
WHILE @No !=0
BEGIN

– get the first o
SELECT @No = CHARINDEX(@Delimiter,@String)

– get the value in the @item variable
IF @No !=0
SELECT @Item = LEFT(@STRING,@No – 1)
ELSE
SELECT @Item = @String

– Put the values in the Result Set
INSERT INTO @Results(Items) VALUES(@Item)

– Remove the item from the main string
SELECT @STRING = RIGHT(@String,LEN(@String) – @No)

– break it work done
IF LEN(@String) = 0 BREAK
END
RETURN

END

Lets check Example of  it:
==============================

Select * from dbo.Split_String(’IT,Marketing,Production’,',’)

Output in table format:
==============================

IT
Marketing
Production

Great! we have all the data in tabular format now which you can easily use anywhere else in your code.

I hope this little function will help you save lot of time and frustration. Please comment if you know any better solution for this.

Posted by Posted by kuldip.bhatt under Filed under Code, SQL Server Comments 1 Comment »

23rd Jul 2009

Magic of Indexing

Today I am going to share something I know about indexing. I am sure you all must be using it somewhere or must have heard of it.

Let’s see one wonderful example of its usage today which will show how important it is to use indexes properly in Database. I would like to thank my client and my mentor Stephen Fegel of Galatea Systems for imparting this wonderful knowledge.

We all use “Select” for retrieving data from the tables. In most cases if data is not too much it takes minimal time to fetch records without indexing also. But in case of large data this may be a severe problem.

Lets take an example:

I have two tables one is houses which is my main table and it has 25,666 records.

And another table is house_desc which has 6,04,255 records.

And the query is

SELECT
SQL_NO_CACHE h.*,
(SELECT
SQL_NO_CACHE desc_value
FROM
house_desc AS d
WHERE
language_id = ‘EN’
AND
d.house_id = h.house_id
AND
(
desc_type = ‘description’
OR
desc_type = ‘introduction’
)
ORDER BY desc_type
LIMIT 0 , 1
)
AS
desc_value
FROM
houses AS h
WHERE
house_id
IN (’12345678′)

Now lets join both the tables and fire sub query for retrieving data from house_desc table.

Structure of the house_desc is

`c_code` varchar(50)
`house_id` int(10)
`country` char(2)
`language_id` enum(’NL’,'EN’,'DE’,'FR’,'ES’,'IT’)
`desc_type` varchar(50)
`desc_value` longtext

So when I fire the query without indexing and I get following result

Showing rows 0 – 0 (1 total, Query took 13.0067 sec)

It returns only 1 row but still it took 13 secs!!

Now just see the magic of indexing here. Just set the index on house_id field
Fire the same query again and here is the result:

Showing rows 0 – 0 (1 total, Query took 0.0899 sec)

Output is same but just look at the difference in time to fetch records!

Before indexing it took 13.0067 seconds and after indexing it took 0.0899 seconds i.e. it is 1000 time faster than without indexing.

The result may be different in your case as in sometimes it can be 100 time faster or 10 time faster but one thing is for sure that it will be faster than without indexing (if done correctly!).

When you have large amount of records in your table and you want to search that table then it is better to set index on those fields which are there in where clause.

You can’t set index on all the fields from table. It is also very important thing on which filed you set the index.

You can read more on indexing from this
http://www.informit.com/articles/article.aspx?p=377652

Posted by Posted by divyang.shah under Filed under Code, php Comments 7 Comments »

21st Jul 2009

Database Connection in QTP

How to connect database with application running in QTP to check data in DB dynamically?

An example is shown connecting QTP with SQL Server

A simple script is shown below with necessary comments :

Dim con,rs,column_count,column_name,i,column_value

Set con=createobject(”adodb.connection”) // Its a connection object
Set rs=createobject(”adodb.recordset”) // A record set should be defined

// Necessary connection string should be their
con.open “provider=sqloledb.1;server=.\SQLEXPRESS;database=DBNAME;user id=XYZ;password=XYZ”

// Finally the record set is defined to fetch the value of particular fields according to the query passed.

rs.open”select * from tbl_newsMaster where username=’admin’”

// Checks the record set till the end until any record is found.If any record is found then it stores the values in “rs” record set.
Do while not rs.eof
For i = 0 To rs.Fields.Count -1
‘ msgbox rs.Fields.Count //counts the number of records in record set “rs”
column_value=rs.Fields(i).value //Fetches the value of particular field stored in record set “rs”
column_name=rs.Fields(i).name
Msgbox “Record Exist :” & column_name&” ” &column_value
next
rs.movenext
Loop

Posted by Posted by jigar.parvatia under Filed under Uncategorized Comments No Comments »